本文整理汇总了C++中QFontDatabase::font方法的典型用法代码示例。如果您正苦于以下问题:C++ QFontDatabase::font方法的具体用法?C++ QFontDatabase::font怎么用?C++ QFontDatabase::font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFontDatabase
的用法示例。
在下文中一共展示了QFontDatabase::font方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: metrics
void tst_QFontMetrics::metrics()
{
QFont font;
QFontDatabase fdb;
// Query the QFontDatabase for a specific font, store the
// result in family, style and size.
QStringList families = fdb.families();
if (families.isEmpty())
return;
QStringList::ConstIterator f_it, f_end = families.end();
for (f_it = families.begin(); f_it != f_end; ++f_it) {
const QString &family = *f_it;
QStringList styles = fdb.styles(family);
QStringList::ConstIterator s_it, s_end = styles.end();
for (s_it = styles.begin(); s_it != s_end; ++s_it) {
const QString &style = *s_it;
if (fdb.isSmoothlyScalable(family, style)) {
// smoothly scalable font... don't need to load every pointsize
font = fdb.font(family, style, 12);
QFontMetrics fontmetrics(font);
QCOMPARE(fontmetrics.ascent() + fontmetrics.descent(),
fontmetrics.height());
QCOMPARE(fontmetrics.height() + fontmetrics.leading(),
fontmetrics.lineSpacing());
} else {
QList<int> sizes = fdb.pointSizes(family, style);
QVERIFY(!sizes.isEmpty());
QList<int>::ConstIterator z_it, z_end = sizes.end();
for (z_it = sizes.begin(); z_it != z_end; ++z_it) {
const int size = *z_it;
// Initialize the font, and check if it is an exact match
font = fdb.font(family, style, size);
QFontMetrics fontmetrics(font);
QCOMPARE(fontmetrics.ascent() + fontmetrics.descent(),
fontmetrics.height());
QCOMPARE(fontmetrics.height() + fontmetrics.leading(),
fontmetrics.lineSpacing());
}
}
}
}
}
示例2: italicOblique
void tst_QFont::italicOblique()
{
QFontDatabase fdb;
QStringList families = fdb.families();
if (families.isEmpty())
return;
QStringList::ConstIterator f_it, f_end = families.end();
for (f_it = families.begin(); f_it != f_end; ++f_it) {
QString family = *f_it;
QStringList styles = fdb.styles(family);
QVERIFY(!styles.isEmpty());
QStringList::ConstIterator s_it, s_end = styles.end();
for (s_it = styles.begin(); s_it != s_end; ++s_it) {
QString style = *s_it;
if (fdb.isSmoothlyScalable(family, style)) {
if (style.contains("Oblique")) {
style.replace("Oblique", "Italic");
} else if (style.contains("Italic")) {
style.replace("Italic", "Oblique");
} else {
continue;
}
QFont f = fdb.font(family, style, 12);
QVERIFY(f.italic());
}
}
}
}
示例3: stripStyleName
QFont stripStyleName(QFont &f, QFontDatabase &db)
{
const QString &styleName = f.styleName();
if (styleName.isEmpty()) {
return f;
} else {
QFont g = (db.styleString(f) != styleName) ?
db.font(f.family(), styleName, f.pointSize())
: QFont(f.family(), f.pointSize(), f.weight());
if (auto s = f.pixelSize() > 0) {
g.setPixelSize(s);
}
g.setStyleHint(f.styleHint(), f.styleStrategy());
g.setStyle(f.style());
if (f.underline()) {
g.setUnderline(true);
}
if (f.strikeOut()) {
g.setStrikeOut(true);
}
if (f.fixedPitch()) {
g.setFixedPitch(true);
}
return g;
}
}
示例4: buildFont
void MainWindow::buildFont()
{
QFontDatabase db;
QFont font = db.font(ui->fontFamilyCombo->currentText(),
ui->fontStyleCombo->currentText(),
ui->pointSizeCombo->currentText().toInt());
ui->sampleLineEdit->setFont(font);
setModified(true);
}
示例5: updateStyle
void CharacterWidget::updateStyle(const QString &fontStyle)
{
QFontDatabase fontDatabase;
const QFont::StyleStrategy oldStrategy = displayFont.styleStrategy();
displayFont = fontDatabase.font(displayFont.family(), fontStyle, displayFont.pointSize());
displayFont.setStyleStrategy(oldStrategy);
calculateSquareSize();
adjustSize();
update();
}
示例6: mCentralWidget
BabelMainWindow::BabelMainWindow(void)
: QMainWindow(), mCentralWidget(new QStackedWidget), mFlyer(new BabelFlyer),
mSignup(new BabelInscription), mSetting(new BabelSetting), mMain(new BabelMain), mUpdate(new BabelUpdate)
{
// Load and set font
this->setWindowTitle("Studio Babel :: VOIP-Epitech 2017");
QFontDatabase fontDb;
QString openSansLightPath = "fonts/OpenSans-Light.ttf";
if (fontDb.addApplicationFont(openSansLightPath) != -1)
{
QFont openSansLightFont = fontDb.font("Open Sans Light", "Normal", -1);
mSignup->setFont(openSansLightFont);
mSetting->setFont(openSansLightFont);
mMain->setFont(openSansLightFont);
}
// set central widget
setCentralWidget(mCentralWidget);
mCentralWidget->addWidget(mMain);
mCentralWidget->addWidget(mFlyer);
mCentralWidget->addWidget(mUpdate);
mCentralWidget->addWidget(mSignup);
mCentralWidget->addWidget(mSetting);
mMain->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
mFlyer->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
mUpdate->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
mSignup->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
mSetting->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
QObject::connect(mSetting, SIGNAL(exit()), this, SLOT(displayFlyer()));
QObject::connect(mSetting, SIGNAL(askForConnection(const QString &, int)), this, SLOT(connectionToServer(const QString &, int)));
QObject::connect(mSignup, SIGNAL(exit()), this, SLOT(displayFlyer()));
QObject::connect(mSignup, SIGNAL(askForRegistration(const Contact &)), this, SLOT(createAccount(const Contact &)));
QObject::connect(mSignup, SIGNAL(displayInformation(const QString &)), this, SLOT(displayInformation(const QString &)));
QObject::connect(mFlyer, SIGNAL(displayRegistration()), this, SLOT(displaySignUp()));
QObject::connect(mFlyer, SIGNAL(displaySettings()), this, SLOT(displayOptions()));
QObject::connect(mFlyer, SIGNAL(askForAuthentication(const Contact &)), this, SLOT(connexionToAccount(const Contact &)));
QObject::connect(mUpdate, SIGNAL(exit()), this, SLOT(displayHome()));
QObject::connect(mUpdate, SIGNAL(updateContactInfo(Contact &)), this, SLOT(updateContactInfo(Contact &)));
QObject::connect(mMain, SIGNAL(addContact(const Contact &)), this, SLOT(addNewContact(const Contact &)));
QObject::connect(mMain, SIGNAL(deleteContact(const Contact &)), this, SLOT(deleteContact(const Contact &)));
QObject::connect(mMain, SIGNAL(sendMessage(const Contact &, const QString &)), this, SLOT(sendMessage(const Contact &, const QString &)));
QObject::connect(mMain, SIGNAL(callContact(const Contact &)), this, SLOT(callContact(const Contact &)));
QObject::connect(mMain, SIGNAL(closeCall(const Contact &)), this, SLOT(closeCall(const Contact &)));
QObject::connect(mMain, SIGNAL(logout()), this, SLOT(disconnectionToAccount()));
QObject::connect(mMain, SIGNAL(updateContactInfo()), this, SLOT(displayUpdate()));
}
示例7: QCOMPARE
void tst_QFontDialog::task256466_wrongStyle()
{
QFontDatabase fdb;
FriendlyFontDialog dialog;
QListView *familyList = reinterpret_cast<QListView*>(dialog.d_func()->familyList);
QListView *styleList = reinterpret_cast<QListView*>(dialog.d_func()->styleList);
QListView *sizeList = reinterpret_cast<QListView*>(dialog.d_func()->sizeList);
for (int i = 0; i < familyList->model()->rowCount(); ++i) {
QModelIndex currentFamily = familyList->model()->index(i, 0);
familyList->setCurrentIndex(currentFamily);
const QFont current = dialog.currentFont(),
expected = fdb.font(currentFamily.data().toString(),
styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt());
QCOMPARE(current.family(), expected.family());
QCOMPARE(current.style(), expected.style());
QCOMPARE(current.pointSizeF(), expected.pointSizeF());
}
}
示例8: setTitles
void ObserverGraphic::setTitles(const QString &title, const QString &xTitle, const QString &yTitle)
{
QFontDatabase qfd;
QFont font = qfd.font("Ubuntu", QString(), 12);
QwtText qtitle(title);
qtitle.setFont(font);
plotter->setTitle(qtitle);
plotter->setAxisFont(0, font);
plotter->setAxisFont(1, font);
plotter->setAxisFont(2, font);
QwtText qxTitle(xTitle);
qxTitle.setFont(font);
plotter->setAxisTitle(QwtPlot::xBottom, qxTitle);
QwtText qyTitle(yTitle);
qyTitle.setFont(font);
plotter->setAxisTitle(QwtPlot::yLeft, qyTitle);
}
示例9: FontBrowserInterface
FontBrowserServer::FontBrowserServer(ProbeInterface *probe, QObject *parent)
: FontBrowserInterface(parent)
, m_selectedFontModel(new FontModel(this))
{
QStandardItemModel *model = new QStandardItemModel(this);
model->setHorizontalHeaderLabels(QStringList() << tr("Fonts") << tr("Smooth sizes"));
QFontDatabase database;
foreach (const QString &family, database.families()) {
QStandardItem *familyItem = new QStandardItem;
familyItem->setText(family);
familyItem->setEditable(false);
familyItem->setData(QFont(family));
foreach (const QString &style, database.styles(family)) {
QStandardItem *styleItem0 = new QStandardItem;
styleItem0->setText(style);
styleItem0->setEditable(false);
styleItem0->setData(database.font(family, style, 10));
QString sizes;
foreach (int points, database.smoothSizes(family, style)) {
sizes += QString::number(points) + ' ';
}
QStandardItem *styleItem1 = new QStandardItem;
styleItem1->setText(sizes.trimmed());
styleItem1->setEditable(false);
styleItem1->setToolTip(sizes.trimmed());
familyItem->appendRow(QList<QStandardItem*>() << styleItem0 << styleItem1);
}
model->appendRow(familyItem);
}
probe->registerModel("com.kdab.GammaRay.FontModel", model);
m_fontSelectionModel = ObjectBroker::selectionModel(model);
connect(m_fontSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
SLOT(updateFonts()));
probe->registerModel("com.kdab.GammaRay.SelectedFontModel", m_selectedFontModel);
}
示例10: exactMatch
void tst_QFont::exactMatch()
{
QFont font;
// Check if a non-existing font hasn't an exact match
font = QFont( "BogusFont", 33 );
QVERIFY( !font.exactMatch() );
#ifdef Q_OS_WIN
QSKIP("Exact matching on windows misses a lot because of the sample chars");
#endif
if (QGuiApplication::platformName() == QLatin1String("xcb")) {
QVERIFY(QFont("sans").exactMatch());
QVERIFY(QFont("sans-serif").exactMatch());
QVERIFY(QFont("serif").exactMatch());
QVERIFY(QFont("monospace").exactMatch());
}
QSKIP("This test is bogus on Unix with support for font aliases in fontconfig");
QFontDatabase fdb;
QList<QFontDatabase::WritingSystem> systems = fdb.writingSystems();
for (int system = 0; system < systems.count(); ++system) {
QStringList families = fdb.families(systems[system]);
if (families.isEmpty())
return;
QStringList::ConstIterator f_it, f_end = families.end();
for (f_it = families.begin(); f_it != f_end; ++f_it) {
const QString &family = *f_it;
if (family.contains('['))
continue;
QStringList styles = fdb.styles(family);
QVERIFY(!styles.isEmpty());
QStringList::ConstIterator s_it, s_end = styles.end();
for (s_it = styles.begin(); s_it != s_end; ++s_it) {
const QString &style = *s_it;
if (fdb.isSmoothlyScalable(family, style)) {
// smoothly scalable font... don't need to load every pointsize
font = fdb.font(family, style, 12);
QFontInfo fontinfo(font);
if (! fontinfo.exactMatch()) {
// Unfortunately, this can fail, since
// QFontDatabase does not fill in all font
// properties. Check to make sure that the
// test didn't fail for obvious reasons
if (fontinfo.family().isEmpty()
&& fontinfo.pointSize() == 0) {
// this is a box rendering engine... this can happen from
// time to time, especially on X11 with iso10646-1 or
// unknown font encodings
continue;
}
#ifdef Q_OS_WIN
if (font.family().startsWith("MS ") || fontinfo.family().startsWith("MS ")) {
/* qDebug("Family matching skipped for MS-Alias font: %s, fontinfo: %s",
font.family().latin1(), fontinfo.family().latin1());
*/
} else
#endif
{
if (!(font.family() == fontinfo.family()
|| fontinfo.family().contains(font.family())
|| fontinfo.family().isEmpty())) {
qDebug("Test about to fail for font: %s, fontinfo: %s",
font.family().toLatin1().constData(),
fontinfo.family().toLatin1().constData());
}
QVERIFY(font.family() == fontinfo.family()
|| fontinfo.family().contains(font.family())
|| fontinfo.family().isEmpty());
}
if (font.pointSize() != -1) {
QVERIFY(font.pointSize() == fontinfo.pointSize());
} else {
QVERIFY(font.pixelSize() == fontinfo.pixelSize());
}
QVERIFY(font.italic() == fontinfo.italic());
if (font.weight() != fontinfo.weight()) {
qDebug("font is %s", font.toString().toLatin1().constData());
}
QVERIFY(font.weight() == fontinfo.weight());
} else {
font.setFixedPitch(!fontinfo.fixedPitch());
QFontInfo fontinfo1(font);
QVERIFY( !fontinfo1.exactMatch() );
font.setFixedPitch(fontinfo.fixedPitch());
QFontInfo fontinfo2(font);
QVERIFY( fontinfo2.exactMatch() );
}
}
//.........这里部分代码省略.........
示例11: fontFamilyHasStyle
bool QgsFontUtils::updateFontViaStyle( QFont& f, const QString& fontstyle, bool fallback )
{
if ( fontstyle.isEmpty() )
{
return false;
}
QFontDatabase fontDB;
if ( !fallback )
{
// does the font even have the requested style?
bool hasstyle = fontFamilyHasStyle( f.family(), fontstyle );
if ( !hasstyle )
{
return false;
}
}
// is the font's style already the same as requested?
if ( fontstyle == fontDB.styleString( f ) )
{
return false;
}
QFont appfont = QApplication::font();
int defaultSize = appfont.pointSize(); // QFontDatabase::font() needs an integer for size
QFont styledfont;
bool foundmatch = false;
// if fontDB.font() fails, it returns the default app font; but, that may be the target style
styledfont = fontDB.font( f.family(), fontstyle, defaultSize );
if ( appfont != styledfont || fontstyle != fontDB.styleString( f ) )
{
foundmatch = true;
}
// default to first found style if requested style is unavailable
// this helps in the situations where the passed-in font has to have a named style applied
if ( fallback && !foundmatch )
{
QFont testFont = QFont( f );
testFont.setPointSize( defaultSize );
// prefer a style that mostly matches the passed-in font
Q_FOREACH ( const QString &style, fontDB.styles( f.family() ) )
{
styledfont = fontDB.font( f.family(), style, defaultSize );
styledfont = styledfont.resolve( f );
if ( testFont.toString() == styledfont.toString() )
{
foundmatch = true;
break;
}
}
// fallback to first style found that works
if ( !foundmatch )
{
Q_FOREACH ( const QString &style, fontDB.styles( f.family() ) )
{
styledfont = fontDB.font( f.family(), style, defaultSize );
if ( QApplication::font() != styledfont )
{
foundmatch = true;
break;
}
}
}
示例12: initWithString
bool CCImage::initWithString(
const char * pText,
int nWidth/* = 0*/,
int nHeight/* = 0*/,
ETextAlign eAlignMask/* = kAlignCenter*/,
const char * pFontName/* = nil*/,
int nSize/* = 0*/)
{
if (!pText)
{
return false;
}
QString fontPath(CCFileUtils::fullPathFromRelativePath(pFontName));
QString fontFamily = pFontName;
QString fontStyle = "Normal";
// font already loaded?
QMap<QString, QString>::iterator fontIter = loadedFontMap.find(fontPath);
if(fontIter == loadedFontMap.end())
{
int fontID = QFontDatabase::addApplicationFont(fontPath);
if(fontID != -1)
{
QStringList familyList = QFontDatabase::applicationFontFamilies(fontID);
if(familyList.size() > 0)
fontFamily = familyList.at(0);
}
loadedFontMap.insert(fontPath, fontFamily);
}
else
{
fontFamily = fontIter.value();
}
QFontDatabase fd;
QFont f = fd.font(fontFamily, fontStyle, nSize);
f.setPixelSize(nSize);
QFontMetrics fm(f);
if (nWidth)
{
m_nWidth = (short)nWidth;
}
else
{
m_nWidth = fm.width(QString(pText));
}
if (nHeight)
{
m_nHeight = (short)nHeight;
}
else
{
m_nHeight = fm.height();
}
m_bHasAlpha = true;
m_bPreMulti = false;
m_pData = new unsigned char[m_nWidth * m_nHeight * 4];
memset(m_pData, 0, m_nWidth * m_nHeight * 4);
m_nBitsPerComponent = 8;
QImage image(m_pData, m_nWidth, m_nHeight, QImage::Format_ARGB32_Premultiplied);
QPainter painter(&image);
painter.setFont(f);
painter.setPen(Qt::white);
int flags = 0;
switch (eAlignMask)
{
case kAlignCenter: // Horizontal center and vertical center.
flags |= Qt::AlignHCenter;
flags |= Qt::AlignVCenter;
break;
case kAlignTop: // Horizontal center and vertical top.
flags |= Qt::AlignHCenter;
flags |= Qt::AlignTop;
break;
case kAlignTopRight: // Horizontal right and vertical top.
flags |= Qt::AlignRight;
flags |= Qt::AlignTop;
break;
case kAlignRight: // Horizontal right and vertical center.
flags |= Qt::AlignRight;
flags |= Qt::AlignVCenter;
break;
case kAlignBottomRight: // Horizontal right and vertical bottom.
flags |= Qt::AlignRight;
flags |= Qt::AlignBottom;
break;
case kAlignBottom: // Horizontal center and vertical bottom.
flags |= Qt::AlignHCenter;
flags |= Qt::AlignBottom;
break;
//.........这里部分代码省略.........
示例13: setFontCharacters
void FontDocument::setFontCharacters(const QString &chars,
const Data::Containers::FontParameters ¶meters)
{
QFontDatabase fonts;
bool regenerateAll = false;
this->mContainer->blockSignals(true);
if (this->mContainer->count() > 1) {
if (this->usedFont().family() != parameters.family ||
this->usedStyle() != parameters.style ||
this->usedFont().pixelSize() != parameters.size ||
this->monospaced() != parameters.monospaced ||
this->antialiasing() != parameters.antiAliasing ||
this->foreground() != parameters.foreground ||
this->background() != parameters.background ||
this->ascent() != parameters.ascent ||
this->descent() != parameters.descent ||
this->multiplicityHeight() != parameters.multiplicityHeight ||
this->multiplicityWidth() != parameters.multiplicityWidth
) {
AppUI::Fonts::DialogFontChanged dialog(qobject_cast<QWidget *>(this->parent()));
if (dialog.exec() == QDialog::Accepted) {
regenerateAll = dialog.regenerateAll();
} else {
return;
}
}
} else { // for newly created fonts
regenerateAll = true;
}
this->beginChanges();
// create font with specified parameters
QFont fontNew = fonts.font(parameters.family, parameters.style, parameters.size);
fontNew.setPixelSize(parameters.size);
if (parameters.antiAliasing) {
fontNew.setStyleStrategy(QFont::PreferAntialias);
} else {
fontNew.setStyleStrategy(QFont::NoAntialias);
}
// remove old characters
if (regenerateAll) {
this->mContainer->clear();
// save new font
this->setUsedFont(fontNew);
this->setUsedStyle(parameters.style);
this->setMonospaced(parameters.monospaced);
this->setAntialiasing(parameters.antiAliasing);
this->setAscent(parameters.ascent);
this->setDescent(parameters.descent);
this->setForeground(parameters.foreground);
this->setBackground(parameters.background);
this->setMultiplicityHeight(parameters.multiplicityHeight);
this->setMultiplicityWidth(parameters.multiplicityWidth);
} else {
// remove characters, which not present in new characters list
QStringList keys = this->mContainer->keys();
QListIterator<QString> it(keys);
it.toFront();
while (it.hasNext()) {
QString a = it.next();
if (!chars.contains(a)) {
this->mContainer->removeImage(a);
}
}
}
// find max size
int width = 0, height = 0;
QFontMetrics metrics(fontNew);
if (parameters.monospaced) {
for (int i = 0; i < chars.count(); i++) {
width = qMax(width, metrics.width(chars.at(i)));
}
height = metrics.height();
}
// generate new characters
QStringList keys = this->mContainer->keys();
QStringList userOrdered;
for (int i = 0; i < chars.count(); i++) {
QString key = QString(chars.at(i));
userOrdered.append(key);
// if character not exists, create it
if (!keys.contains(key)) {
keys.append(key);
QImage image = Parsing::Conversion::FontHelper::drawCharacter(chars.at(i),
//.........这里部分代码省略.........
示例14: main
int main(int argc, char *argv[])
{
QFile logfile2("C:/i8910tuninglog.txt");
QTextStream log2(&logfile2);
if (!logfile2.open(QIODevice::Append | QIODevice::WriteOnly)) return 1;
#ifdef Q_OS_SYMBIAN
QApplication::setGraphicsSystem("openvg");
#endif
QApplication app(argc, argv);
#ifdef Q_OS_SYMBIAN
//LEAVES IF E: DRIVE IS BUSY (I.E. PHONE IS PLUGGED IN USB MASS STORAGE MODE)
RFs fsSession;
CleanupClosePushL(fsSession);
User::LeaveIfError(fsSession.Connect());
TVolumeInfo volumeInfo;
TInt err=fsSession.Volume(volumeInfo,EDriveE);
if (err==KErrNotReady)
{
fsSession.Close();
CleanupStack::PopAndDestroy();
QPixmap pixmap(":/images/exitsplash.png");
QSplashScreen splash(pixmap);
splash.showFullScreen();
User::After(5000000);
app.quit();
}
fsSession.Close();
CleanupStack::PopAndDestroy();
#endif
QPixmap pixmap(":/images/splashscreen.png");
QSplashScreen splash(pixmap);
splash.showFullScreen();
QFontDatabase fontdb;
int bella = fontdb.addApplicationFont("E:/data/SymbianTuning/SegoeWP.ttf");
qDebug() << QString::number(bella);
QFont fontnew = fontdb.font("Segoe WP", "Normal", 7);
app.setFont(fontnew);
QDeclarativeView view;
#ifdef Q_OS_SYMBIAN
//view.setAttribute(Qt::WA_NoSystemBackground);
#endif
view.rootContext()->setContextProperty("i8910tuning", new i8910tuning(0, &logfile2, &log2));
view.setSource(QUrl("qrc:/Page.qml"));
QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
#ifdef Q_OS_SYMBIAN
CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
TRAPD(error,
if (appUi) {
// Lock application orientation into landscape
appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
}
);
示例15: fileSave
void MainWindow::fileSave()
{
if (! modified) {
statusBar()->showMessage(tr("No changes to be saved."), 2000);
return;
}
statusBar()->showMessage(tr("Saving changes..."));
{
QSettings settings(QLatin1String("QtProject"));
settings.beginGroup(QLatin1String("Qt"));
QFontDatabase db;
QFont font = db.font(ui->fontFamilyCombo->currentText(),
ui->fontStyleCombo->currentText(),
ui->pointSizeCombo->currentText().toInt());
QStringList actcg, inactcg, discg;
bool overrideDesktopSettings = (ui->guiStyleCombo->currentText() != desktopThemeName);
if (overrideDesktopSettings) {
int i;
for (i = 0; i < QPalette::NColorRoles; i++)
actcg << editPalette.color(QPalette::Active,
QPalette::ColorRole(i)).name();
for (i = 0; i < QPalette::NColorRoles; i++)
inactcg << editPalette.color(QPalette::Inactive,
QPalette::ColorRole(i)).name();
for (i = 0; i < QPalette::NColorRoles; i++)
discg << editPalette.color(QPalette::Disabled,
QPalette::ColorRole(i)).name();
}
settings.setValue(QLatin1String("font"), font.toString());
settings.setValue(QLatin1String("Palette/active"), actcg);
settings.setValue(QLatin1String("Palette/inactive"), inactcg);
settings.setValue(QLatin1String("Palette/disabled"), discg);
settings.setValue(QLatin1String("fontPath"), fontpaths);
settings.setValue(QLatin1String("embedFonts"), ui->fontEmbeddingCheckBox->isChecked());
settings.setValue(QLatin1String("style"),
overrideDesktopSettings ? ui->guiStyleCombo->currentText() : QString());
settings.setValue(QLatin1String("doubleClickInterval"), ui->doubleClickIntervalSpinBox->value());
settings.setValue(QLatin1String("cursorFlashTime"),
ui->cursorFlashTimeSpinBox->value() == 9 ? 0 : ui->cursorFlashTimeSpinBox->value());
settings.setValue(QLatin1String("wheelScrollLines"), ui->wheelScrollLinesSpinBox->value());
settings.setValue(QLatin1String("resolveSymlinks"), ui->resolveLinksCheckBox->isChecked());
QSize strut(ui->strutWidthSpinBox->value(), ui->strutHeightSpinBox->value());
settings.setValue(QLatin1String("globalStrut/width"), strut.width());
settings.setValue(QLatin1String("globalStrut/height"), strut.height());
settings.setValue(QLatin1String("useRtlExtensions"), ui->rtlExtensionsCheckBox->isChecked());
#ifdef Q_WS_X11
QString style = ui->inputStyleCombo->currentText();
QString str = QLatin1String("On The Spot");
if (style == tr("Over The Spot"))
str = QLatin1String("Over The Spot");
else if (style == tr("Off The Spot"))
str = QLatin1String("Off The Spot");
else if (style == tr("Root"))
str = QLatin1String("Root");
settings.setValue(QLatin1String("XIMInputStyle"), str);
#endif
#if defined(Q_WS_X11) && !defined(QT_NO_XIM)
settings.setValue(QLatin1String("DefaultInputMethod"), ui->inputMethodCombo->currentText());
#endif
QStringList effects;
if (ui->effectsCheckBox->isChecked()) {
effects << QLatin1String("general");
switch (ui->menuEffectCombo->currentIndex()) {
case 1: effects << QLatin1String("animatemenu"); break;
case 2: effects << QLatin1String("fademenu"); break;
}
switch (ui->comboEffectCombo->currentIndex()) {
case 1: effects << QLatin1String("animatecombo"); break;
}
switch (ui->toolTipEffectCombo->currentIndex()) {
case 1: effects << QLatin1String("animatetooltip"); break;
case 2: effects << QLatin1String("fadetooltip"); break;
}
switch (ui->toolBoxEffectCombo->currentIndex()) {
case 1: effects << QLatin1String("animatetoolbox"); break;
}
} else
effects << QLatin1String("none");
settings.setValue(QLatin1String("GUIEffects"), effects);
QStringList familysubs = QFont::substitutions();
QStringList::Iterator fit = familysubs.begin();
settings.beginGroup(QLatin1String("Font Substitutions"));
while (fit != familysubs.end()) {
QStringList subs = QFont::substitutes(*fit);
settings.setValue(*fit, subs);
//.........这里部分代码省略.........