kdeui: prepare for Katie changes

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-11-19 05:02:18 +02:00
parent 7555229053
commit c43d9e8df7
5 changed files with 15 additions and 41 deletions

View file

@ -151,7 +151,7 @@ static bool writeEntryGui(KConfigGroup *cg, const char* key, const QVariant &pro
return true; return true;
} }
case QVariant::Font: case QVariant::Font:
cg->writeEntry( key, prop.toString().toUtf8(), pFlags ); cg->writeEntry( key, prop.toString(), pFlags );
return true; return true;
case QVariant::Pixmap: case QVariant::Pixmap:

View file

@ -655,7 +655,7 @@ void KFontChooser::Private::_k_family_chosen_slot(const QString& family)
sizeOfFont->setValue(currentSize); sizeOfFont->setValue(currentSize);
selFont = dbase.font(currentFamily, currentStyle, int(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); selFont.setPointSizeF(currentSize);
} }
emit q->fontSelected(selFont); emit q->fontSelected(selFont);
@ -684,7 +684,7 @@ void KFontChooser::Private::_k_style_chosen_slot(const QString& style)
sizeOfFont->setValue(currentSize); sizeOfFont->setValue(currentSize);
selFont = dbase.font(currentFamily, currentStyle, int(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); selFont.setPointSizeF(currentSize);
} }
emit q->fontSelected(selFont); emit q->fontSelected(selFont);
@ -748,32 +748,7 @@ void KFontChooser::Private::_k_size_value_slot(double dval)
customSizeRow = -1; customSizeRow = -1;
} }
bool canCustomize = true; bool canCustomize = dbase.isScalable(family, style);
// 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);
}
// Set the current size in the size listbox. // Set the current size in the size listbox.
int row = nearestSizeRow(val, canCustomize); int row = nearestSizeRow(val, canCustomize);
@ -863,14 +838,14 @@ qreal KFontChooser::Private::setupSizeListBox (const QString& family, const QStr
{ {
QFontDatabase dbase; QFontDatabase dbase;
QList<qreal> sizes; QList<qreal> sizes;
if (dbase.isSmoothlyScalable(family, style)) { if (dbase.isScalable(family, style)) {
// A vector font. // A vector font.
//>sampleEdit->setPaletteBackgroundPixmap( VectorPixmap ); // TODO //>sampleEdit->setPaletteBackgroundPixmap( VectorPixmap ); // TODO
} else { } else {
// A bitmap font. // A bitmap font.
//sampleEdit->setPaletteBackgroundPixmap( BitmapPixmap ); // TODO //sampleEdit->setPaletteBackgroundPixmap( BitmapPixmap ); // TODO
QList<int> smoothSizes = dbase.smoothSizes(family, style); QList<int> pointSizes = dbase.pointSizes(family, style);
foreach (const int size, smoothSizes) { foreach (const int size, pointSizes) {
sizes.append(qreal(size)); sizes.append(qreal(size));
} }
} }
@ -976,7 +951,7 @@ void KFontChooser::Private::setupDisplay()
// otherwise just select the nearest available size. // otherwise just select the nearest available size.
QString currentFamily = qtFamilies[familyListBox->currentItem()->text()]; QString currentFamily = qtFamilies[familyListBox->currentItem()->text()];
QString currentStyle = qtStyles[styleListBox->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)); sizeListBox->setCurrentRow(nearestSizeRow(size, canCustomize));
// Set current size in the spinbox. // 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) for (QStringList::const_iterator it = lstSys.constBegin(); it != lstSys.constEnd(); ++it)
{ {
if ((fontListCriteria & FixedWidthFonts) > 0 && !dbase.isFixedPitch(*it)) continue; 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); lstFonts.append(*it);
} }

View file

@ -107,7 +107,7 @@ void KFontFamilyDelegate::paint (QPainter *painter,
// Choose and paint an icon according to the font type, scalable or bitmat. // Choose and paint an icon according to the font type, scalable or bitmat.
const QIcon *icon = &bitmap; const QIcon *icon = &bitmap;
if (fontdb.isSmoothlyScalable(fontFamily)) { if (fontdb.isScalable(fontFamily)) {
icon = &truetype; icon = &truetype;
} }
QRect r = option.rect; QRect r = option.rect;

View file

@ -51,13 +51,12 @@ static QFont nearestExistingFont (const QFont &font)
// Check if the family has the requested style. // Check if the family has the requested style.
// Easiest by piping it through font selection in the database. // Easiest by piping it through font selection in the database.
QString retStyle = dbase.styleString(dbase.font(family, style, 10)); style = dbase.styleString(dbase.font(family, style, 10));
style = retStyle;
// Check if the family has the requested size. // Check if the family has the requested size.
// Only for bitmap fonts. // Only for bitmap fonts.
if (!dbase.isSmoothlyScalable(family, style)) { if (!dbase.isScalable(family, style)) {
QList<int> sizes = dbase.smoothSizes(family, style); QList<int> sizes = dbase.pointSizes(family, style);
if (!sizes.contains(size)) { if (!sizes.contains(size)) {
// Find nearest available size. // Find nearest available size.
int mindiff = 1000; int mindiff = 1000;
@ -74,7 +73,7 @@ static QFont nearestExistingFont (const QFont &font)
// Select the font with confirmed properties. // Select the font with confirmed properties.
QFont result = dbase.font(family, style, int(size)); 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); result.setPointSizeF(size);
} }
return result; return result;

View file

@ -432,7 +432,7 @@ QFont KGlobalSettingsData::largeFont( const QString& text )
for(QStringList::ConstIterator it = fam.constBegin(); for(QStringList::ConstIterator it = fam.constBegin();
it != fam.constEnd(); ++it) it != fam.constEnd(); ++it)
{ {
if (db.isSmoothlyScalable(*it) && !db.isFixedPitch(*it)) if (db.isScalable(*it) && !db.isFixedPitch(*it))
{ {
QFont font(*it); QFont font(*it);
font.setPixelSize(75); font.setPixelSize(75);