Changeset View
Changeset View
Standalone View
Standalone View
kded/configvalueprovider.cpp
Show All 40 Lines | |||||
41 | { | 41 | { | ||
42 | static const QFont defaultFont(QStringLiteral("Noto Sans"), 10); | 42 | static const QFont defaultFont(QStringLiteral("Noto Sans"), 10); | ||
43 | 43 | | |||
44 | kdeglobalsConfig->reparseConfiguration(); | 44 | kdeglobalsConfig->reparseConfiguration(); | ||
45 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("General")); | 45 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("General")); | ||
46 | QString fontAsString = configGroup.readEntry(QStringLiteral("font"), defaultFont.toString()); | 46 | QString fontAsString = configGroup.readEntry(QStringLiteral("font"), defaultFont.toString()); | ||
47 | static QFont font; | 47 | static QFont font; | ||
48 | font.fromString(fontAsString); | 48 | font.fromString(fontAsString); | ||
49 | return font.family() + QStringLiteral(", ") + font.styleName() + ' ' + QString::number(font.pointSize()); | 49 | const QString fontStyle = fontStyleHelper(font); | ||
50 | return font.family() + QStringLiteral(", ") + fontStyle + ' ' + QString::number(font.pointSize()); | ||||
chauvin: I think
```
QStringLiteral(", ")
```
should be replaced by a space (see my [[ https://bugs. | |||||
Comma is important, if not the comma, the GTK would not be able to parse font with spaces in name. Comma fixed that bug: https://bugs.kde.org/show_bug.cgi?id=380980 gikari: Comma is important, if not the comma, the GTK would not be able to parse font with spaces in… | |||||
I observed a different behavior with ~/.gtkrc-2.0 (libgtk version 2.62.1) chauvin: I observed a different behavior with ~/.gtkrc-2.0 (libgtk version 2.62.1)
There is perhaps a… | |||||
Sorry I missread the version of libgtk2.0 it is 2.24.32 (not 2.62.1) It works with the following line in ~/.gtkrc-2.0: gtk-font-name="Ubuntu, Light 11" gtk-font-name="Ubuntu Light Regular 11" but it doesn't work with: gtk-font-name="Ubuntu Light, Regular 11" So I assume it is a bug in gtk2 parser and the comma is not the problem I am not sure but I think the parsing is done in this function: chauvin: Sorry I missread the version of libgtk2.0 it is 2.24.32 (not 2.62.1)
It works with the… | |||||
50 | } | 51 | } | ||
51 | 52 | | |||
53 | QString ConfigValueProvider::fontStyleHelper(const QFont &font) const | ||||
ervin: Space should be before & not after | |||||
54 | { | ||||
55 | // BUG: 333146 | ||||
56 | // Since Qt sometimes gives us wrong font style name, | ||||
57 | // we ought to use this big helper function to construct | ||||
58 | // the style ourselves. Some fonts will not work | ||||
59 | auto weight = font.weight(); | ||||
60 | QString result; | ||||
61 | if (weight > QFont::Normal) { | ||||
62 | if (weight >= QFont::Black) { | ||||
63 | result = QStringLiteral("Black"); | ||||
64 | } else if (weight >= QFont::ExtraBold) { | ||||
65 | result = QStringLiteral("Extra Bold"); | ||||
66 | } else if (weight >= QFont::Bold) { | ||||
67 | result = QStringLiteral("Bold"); | ||||
68 | } else if (weight >= QFont::DemiBold) { | ||||
69 | result = QStringLiteral("Demi Bold"); | ||||
70 | } else if (weight >= QFont::Medium) { | ||||
71 | result = QStringLiteral("Medium"); | ||||
72 | } | ||||
73 | } else { | ||||
74 | if (weight <= QFont::Thin) { | ||||
75 | result = QStringLiteral("Thin"); | ||||
76 | } else if (weight <= QFont::ExtraLight) { | ||||
77 | result = QStringLiteral("Extra Light"); | ||||
78 | } else if (weight <= QFont::Light) { | ||||
79 | result = QStringLiteral("Light"); | ||||
80 | } | ||||
81 | } | ||||
82 | | ||||
83 | auto style = font.style(); | ||||
84 | if (style == QFont::StyleItalic) { | ||||
85 | result += QLatin1Char(' ') + QStringLiteral("Italic"); | ||||
86 | } else if (style == QFont::StyleOblique) { | ||||
87 | result += QLatin1Char(' ') + QStringLiteral("Oblique"); | ||||
88 | } | ||||
89 | | ||||
90 | auto stretch = font.stretch(); | ||||
91 | if (stretch == QFont::UltraCondensed) { | ||||
92 | result += QLatin1Char(' ') + QStringLiteral("UltraCondensed"); | ||||
93 | } else if (stretch == QFont::ExtraCondensed) { | ||||
94 | result += QLatin1Char(' ') + QStringLiteral("ExtraCondensed"); | ||||
95 | } else if (stretch == QFont::Condensed) { | ||||
96 | result += QLatin1Char(' ') + QStringLiteral("Condensed"); | ||||
97 | } else if (stretch == QFont::SemiCondensed) { | ||||
98 | result += QLatin1Char(' ') + QStringLiteral("SemiCondensed"); | ||||
99 | } else if (stretch == QFont::Unstretched) { | ||||
100 | result += QLatin1Char(' ') + QStringLiteral("Unstretched"); | ||||
101 | } else if (stretch == QFont::SemiExpanded) { | ||||
102 | result += QLatin1Char(' ') + QStringLiteral("SemiExpanded"); | ||||
103 | } else if (stretch == QFont::Expanded) { | ||||
104 | result += QLatin1Char(' ') + QStringLiteral("Expanded"); | ||||
105 | } else if (stretch == QFont::ExtraExpanded) { | ||||
106 | result += QLatin1Char(' ') + QStringLiteral("ExtraExpanded"); | ||||
107 | } else if (stretch == QFont::UltraExpanded) { | ||||
108 | result += QLatin1Char(' ') + QStringLiteral("UltraExpanded"); | ||||
109 | } | ||||
110 | | ||||
111 | return result.simplified(); | ||||
112 | } | ||||
113 | | ||||
114 | | ||||
52 | QString ConfigValueProvider::iconThemeName() const | 115 | QString ConfigValueProvider::iconThemeName() const | ||
53 | { | 116 | { | ||
54 | KIconTheme *newIconTheme = KIconLoader::global()->theme(); | 117 | KIconTheme *newIconTheme = KIconLoader::global()->theme(); | ||
55 | if (newIconTheme) { | 118 | if (newIconTheme) { | ||
56 | return newIconTheme->internalName(); | 119 | return newIconTheme->internalName(); | ||
57 | } else { | 120 | } else { | ||
58 | return QStringLiteral("breeze"); | 121 | return QStringLiteral("breeze"); | ||
59 | } | 122 | } | ||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |
I think
should be replaced by a space (see my comment)
however I don't know what will happen in ambigious cases such like:
"DejaVu Sans" + " " + "Condensed Bold" + " " +"11"
and
"DejaVu Sans Condensed" + " " + "Bold" + " " +"11"