diff --git a/src/kfontchooser.cpp b/src/kfontchooser.cpp --- a/src/kfontchooser.cpp +++ b/src/kfontchooser.cpp @@ -110,6 +110,8 @@ KFontChooser *q; + QFontDatabase fdb; + QPalette m_palette; QDoubleSpinBox *sizeOfFont = nullptr; @@ -554,8 +556,7 @@ } // Get the list of styles available in this family. - QFontDatabase dbase; - QStringList styles = dbase.styles(currentFamily); + QStringList styles = fdb.styles(currentFamily); if (styles.isEmpty()) { // Avoid extraction, it is in kdeqt.po styles.append(TR_NOX("Normal", "QFontDatabase")); @@ -573,8 +574,8 @@ // Sometimes the font database will report an invalid style, // that falls back back to another when set. // Remove such styles, by checking set/get round-trip. - QFont testFont = dbase.font(currentFamily, style, 10); - if (dbase.styleString(testFont) != style) { + QFont testFont = fdb.font(currentFamily, style, 10); + if (fdb.styleString(testFont) != style) { styles.removeAll(style); continue; } @@ -616,8 +617,8 @@ qreal currentSize = setupSizeListBox(currentFamily, currentStyle); sizeOfFont->setValue(currentSize); - selFont = dbase.font(currentFamily, currentStyle, int(currentSize)); - if (dbase.isSmoothlyScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) { + selFont = fdb.font(currentFamily, currentStyle, int(currentSize)); + if (fdb.isSmoothlyScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) { selFont.setPointSizeF(currentSize); } emit q->fontSelected(selFont); @@ -632,7 +633,6 @@ } signalsAllowed = false; - QFontDatabase dbase; QString currentFamily = qtFamilies[familyListBox->currentItem()->text()]; QString currentStyle; if (style.isEmpty()) { @@ -645,8 +645,8 @@ qreal currentSize = setupSizeListBox(currentFamily, currentStyle); sizeOfFont->setValue(currentSize); - selFont = dbase.font(currentFamily, currentStyle, int(currentSize)); - if (dbase.isSmoothlyScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) { + selFont = fdb.font(currentFamily, currentStyle, int(currentSize)); + if (fdb.isSmoothlyScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) { selFont.setPointSizeF(currentSize); } emit q->fontSelected(selFont); @@ -700,7 +700,6 @@ // We compare with qreal, so convert for platforms where qreal != double. qreal val = qreal(dval); - QFontDatabase dbase; QString family = qtFamilies[familyListBox->currentItem()->text()]; QString style = qtStyles[styleListBox->currentItem()->text()]; @@ -713,7 +712,7 @@ bool canCustomize = true; // For Qt-bad-sizes workaround: skip this block unconditionally - if (!dbase.isSmoothlyScalable(family, style)) { + if (!fdb.isSmoothlyScalable(family, style)) { // Bitmap font, allow only discrete sizes. // Determine the nearest in the direction of change. canCustomize = false; @@ -825,11 +824,10 @@ qreal KFontChooser::Private::setupSizeListBox(const QString &family, const QString &style) { - QFontDatabase dbase; QList sizes; - const bool smoothlyScalable = dbase.isSmoothlyScalable(family, style); + const bool smoothlyScalable = fdb.isSmoothlyScalable(family, style); if (!smoothlyScalable) { - const QList smoothSizes = dbase.smoothSizes(family, style); + const QList smoothSizes = fdb.smoothSizes(family, style); for (int size : smoothSizes) { sizes.append(size); } @@ -851,7 +849,6 @@ void KFontChooser::Private::setupDisplay() { - QFontDatabase dbase; QString family = selFont.family().toLower(); QString styleID = styleIdentifier(selFont); qreal size = selFont.pointSizeF(); @@ -932,7 +929,7 @@ // otherwise just select the nearest available size. QString currentFamily = qtFamilies[familyListBox->currentItem()->text()]; QString currentStyle = qtStyles[styleListBox->currentItem()->text()]; - bool canCustomize = dbase.isSmoothlyScalable(currentFamily, currentStyle); + bool canCustomize = fdb.isSmoothlyScalable(currentFamily, currentStyle); sizeListBox->setCurrentRow(nearestSizeRow(size, canCustomize)); // Set current size in the spinbox.