Skip to content

Commit

Permalink
Settings: include styleName in font (#2568)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlaltca authored Nov 23, 2023
1 parent a0f2687 commit 00074d1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/kvilib/ext/KviStringConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,6 @@ namespace KviStringConversion
void toString(const QFont & font, QString & szBuffer)
{
QString szFamily(font.family());
szBuffer = QString::asprintf("%s,%d,%d,%d", szFamily.toUtf8().data(), font.pointSize(), font.styleHint(),
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
font.weight()
#else
font.legacyWeight()
#endif
);
QString szOptions;
if(font.bold())
szOptions.append('b');
Expand All @@ -245,11 +238,15 @@ namespace KviStringConversion
if(font.fixedPitch())
szOptions.append('f');

if(!szOptions.isEmpty())
{
szBuffer.append(',');
szBuffer.append(szOptions);
}
szBuffer = QString::asprintf("%s,%d,%d,%d,%s,%s", szFamily.toUtf8().data(), font.pointSize(), font.styleHint(),
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
font.weight(),
#else
font.legacyWeight(),
#endif
szOptions.toUtf8().data(),
font.styleName().toUtf8().data()
);
}

bool fromString(const QString & szValue, QFont & buffer)
Expand All @@ -260,6 +257,7 @@ namespace KviStringConversion
str.getToken(pointSize, ',');
str.getToken(styleHint, ',');
str.getToken(weight, ',');
str.getToken(options, ',');
if(!family.isEmpty())
buffer.setFamily(family.ptr());
int i;
Expand All @@ -277,11 +275,13 @@ namespace KviStringConversion
#else
buffer.setLegacyWeight(i);
#endif
buffer.setBold(str.contains("b"));
buffer.setItalic(str.contains("i"));
buffer.setUnderline(str.contains("u"));
buffer.setStrikeOut(str.contains("s"));
buffer.setFixedPitch(str.contains("f"));
buffer.setBold(options.contains("b"));
buffer.setItalic(options.contains("i"));
buffer.setUnderline(options.contains("u"));
buffer.setStrikeOut(options.contains("s"));
buffer.setFixedPitch(options.contains("f"));
if(!str.isEmpty())
buffer.setStyleName(str.ptr());
return true;
}

Expand Down

0 comments on commit 00074d1

Please sign in to comment.