From c43d9e8df7186a994c1ab6045a498ee12bd1d110 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 19 Nov 2022 05:02:18 +0200 Subject: [PATCH] kdeui: prepare for Katie changes Signed-off-by: Ivailo Monev --- kdeui/config/kconfiggroupgui.cpp | 2 +- kdeui/fonts/kfontchooser.cpp | 41 +++++++------------------------- kdeui/fonts/kfontcombobox.cpp | 2 +- kdeui/fonts/kfontrequester.cpp | 9 ++++--- kdeui/kernel/kglobalsettings.cpp | 2 +- 5 files changed, 15 insertions(+), 41 deletions(-) diff --git a/kdeui/config/kconfiggroupgui.cpp b/kdeui/config/kconfiggroupgui.cpp index 7ee61471..725f9021 100644 --- a/kdeui/config/kconfiggroupgui.cpp +++ b/kdeui/config/kconfiggroupgui.cpp @@ -151,7 +151,7 @@ static bool writeEntryGui(KConfigGroup *cg, const char* key, const QVariant &pro return true; } case QVariant::Font: - cg->writeEntry( key, prop.toString().toUtf8(), pFlags ); + cg->writeEntry( key, prop.toString(), pFlags ); return true; case QVariant::Pixmap: diff --git a/kdeui/fonts/kfontchooser.cpp b/kdeui/fonts/kfontchooser.cpp index bb9d26b7..bd74bec7 100644 --- a/kdeui/fonts/kfontchooser.cpp +++ b/kdeui/fonts/kfontchooser.cpp @@ -655,7 +655,7 @@ void KFontChooser::Private::_k_family_chosen_slot(const QString& family) sizeOfFont->setValue(currentSize); selFont = dbase.font(currentFamily, currentStyle, int(currentSize)); - if (dbase.isSmoothlyScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) { + if (dbase.isScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) { selFont.setPointSizeF(currentSize); } emit q->fontSelected(selFont); @@ -684,7 +684,7 @@ void KFontChooser::Private::_k_style_chosen_slot(const QString& style) sizeOfFont->setValue(currentSize); selFont = dbase.font(currentFamily, currentStyle, int(currentSize)); - if (dbase.isSmoothlyScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) { + if (dbase.isScalable(currentFamily, currentStyle) && selFont.pointSize() == floor(currentSize)) { selFont.setPointSizeF(currentSize); } emit q->fontSelected(selFont); @@ -748,32 +748,7 @@ void KFontChooser::Private::_k_size_value_slot(double dval) customSizeRow = -1; } - bool canCustomize = true; - - // For Qt-bad-sizes workaround: skip this block unconditionally - if (!dbase.isSmoothlyScalable(family, style)) { - // Bitmap font, allow only discrete sizes. - // Determine the nearest in the direction of change. - canCustomize = false; - int nrows = sizeListBox->count(); - int row = sizeListBox->currentRow(); - int nrow; - if (val - selFont.pointSizeF() > 0) { - for (nrow = row + 1; nrow < nrows; ++nrow) - if (KGlobal::locale()->readNumber(sizeListBox->item(nrow)->text()) >= val) - break; - } - else { - for (nrow = row - 1; nrow >= 0; --nrow) - if (KGlobal::locale()->readNumber(sizeListBox->item(nrow)->text()) <= val) - break; - } - // Make sure the new row is not out of bounds. - nrow = nrow < 0 ? 0 : nrow >= nrows ? nrows - 1 : nrow; - // Get the size from the new row and set the spinbox to that size. - val = KGlobal::locale()->readNumber(sizeListBox->item(nrow)->text()); - sizeOfFont->setValue(val); - } + bool canCustomize = dbase.isScalable(family, style); // Set the current size in the size listbox. int row = nearestSizeRow(val, canCustomize); @@ -863,14 +838,14 @@ qreal KFontChooser::Private::setupSizeListBox (const QString& family, const QStr { QFontDatabase dbase; QList sizes; - if (dbase.isSmoothlyScalable(family, style)) { + if (dbase.isScalable(family, style)) { // A vector font. //>sampleEdit->setPaletteBackgroundPixmap( VectorPixmap ); // TODO } else { // A bitmap font. //sampleEdit->setPaletteBackgroundPixmap( BitmapPixmap ); // TODO - QList smoothSizes = dbase.smoothSizes(family, style); - foreach (const int size, smoothSizes) { + QList pointSizes = dbase.pointSizes(family, style); + foreach (const int size, pointSizes) { sizes.append(qreal(size)); } } @@ -976,7 +951,7 @@ void KFontChooser::Private::setupDisplay() // 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 = dbase.isScalable(currentFamily, currentStyle); sizeListBox->setCurrentRow(nearestSizeRow(size, canCustomize)); // Set current size in the spinbox. @@ -996,7 +971,7 @@ void KFontChooser::getFontList( QStringList &list, uint fontListCriteria) for (QStringList::const_iterator it = lstSys.constBegin(); it != lstSys.constEnd(); ++it) { if ((fontListCriteria & FixedWidthFonts) > 0 && !dbase.isFixedPitch(*it)) continue; - if ((fontListCriteria & SmoothScalableFonts) > 0 && !dbase.isSmoothlyScalable(*it)) continue; + if ((fontListCriteria & SmoothScalableFonts) > 0 && !dbase.isScalable(*it)) continue; lstFonts.append(*it); } diff --git a/kdeui/fonts/kfontcombobox.cpp b/kdeui/fonts/kfontcombobox.cpp index 53e288de..0844f52b 100644 --- a/kdeui/fonts/kfontcombobox.cpp +++ b/kdeui/fonts/kfontcombobox.cpp @@ -107,7 +107,7 @@ void KFontFamilyDelegate::paint (QPainter *painter, // Choose and paint an icon according to the font type, scalable or bitmat. const QIcon *icon = &bitmap; - if (fontdb.isSmoothlyScalable(fontFamily)) { + if (fontdb.isScalable(fontFamily)) { icon = &truetype; } QRect r = option.rect; diff --git a/kdeui/fonts/kfontrequester.cpp b/kdeui/fonts/kfontrequester.cpp index 55c568f4..3164839b 100644 --- a/kdeui/fonts/kfontrequester.cpp +++ b/kdeui/fonts/kfontrequester.cpp @@ -51,13 +51,12 @@ static QFont nearestExistingFont (const QFont &font) // Check if the family has the requested style. // Easiest by piping it through font selection in the database. - QString retStyle = dbase.styleString(dbase.font(family, style, 10)); - style = retStyle; + style = dbase.styleString(dbase.font(family, style, 10)); // Check if the family has the requested size. // Only for bitmap fonts. - if (!dbase.isSmoothlyScalable(family, style)) { - QList sizes = dbase.smoothSizes(family, style); + if (!dbase.isScalable(family, style)) { + QList sizes = dbase.pointSizes(family, style); if (!sizes.contains(size)) { // Find nearest available size. int mindiff = 1000; @@ -74,7 +73,7 @@ static QFont nearestExistingFont (const QFont &font) // Select the font with confirmed properties. QFont result = dbase.font(family, style, int(size)); - if (dbase.isSmoothlyScalable(family, style) && result.pointSize() == floor(size)) { + if (dbase.isScalable(family, style) && result.pointSize() == floor(size)) { result.setPointSizeF(size); } return result; diff --git a/kdeui/kernel/kglobalsettings.cpp b/kdeui/kernel/kglobalsettings.cpp index cf6bc146..46410dc2 100644 --- a/kdeui/kernel/kglobalsettings.cpp +++ b/kdeui/kernel/kglobalsettings.cpp @@ -432,7 +432,7 @@ QFont KGlobalSettingsData::largeFont( const QString& text ) for(QStringList::ConstIterator it = fam.constBegin(); it != fam.constEnd(); ++it) { - if (db.isSmoothlyScalable(*it) && !db.isFixedPitch(*it)) + if (db.isScalable(*it) && !db.isFixedPitch(*it)) { QFont font(*it); font.setPixelSize(75);