Changeset View
Changeset View
Standalone View
Standalone View
kded/configvalueprovider.cpp
Show All 25 Lines | |||||
26 | #include <KIconTheme> | 26 | #include <KIconTheme> | ||
27 | #include <KSharedConfig> | 27 | #include <KSharedConfig> | ||
28 | #include <KConfigGroup> | 28 | #include <KConfigGroup> | ||
29 | 29 | | |||
30 | #include "configvalueprovider.h" | 30 | #include "configvalueprovider.h" | ||
31 | 31 | | |||
32 | ConfigValueProvider::ConfigValueProvider() : | 32 | ConfigValueProvider::ConfigValueProvider() : | ||
33 | kdeglobalsConfig(KSharedConfig::openConfig(QStringLiteral("kdeglobals"))), | 33 | kdeglobalsConfig(KSharedConfig::openConfig(QStringLiteral("kdeglobals"))), | ||
34 | inputConfig(KSharedConfig::openConfig(QStringLiteral("kcminputrc"))) | 34 | inputConfig(KSharedConfig::openConfig(QStringLiteral("kcminputrc"))), | ||
35 | kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc"))) | ||||
35 | { | 36 | { | ||
36 | 37 | | |||
37 | } | 38 | } | ||
38 | 39 | | |||
39 | QString ConfigValueProvider::fontName() const | 40 | QString ConfigValueProvider::fontName() const | ||
40 | { | 41 | { | ||
41 | static const QFont defaultFont(QStringLiteral("Noto Sans"), 10); | 42 | static const QFont defaultFont(QStringLiteral("Noto Sans"), 10); | ||
42 | 43 | | |||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 116 | { | |||
121 | // We use heuristic to determine if current color scheme is dark or not | 122 | // We use heuristic to determine if current color scheme is dark or not | ||
122 | if (windowBackgroundGray >= 192) { | 123 | if (windowBackgroundGray >= 192) { | ||
123 | return QStringLiteral("0"); | 124 | return QStringLiteral("0"); | ||
124 | } else { | 125 | } else { | ||
125 | return QStringLiteral("1"); | 126 | return QStringLiteral("1"); | ||
126 | } | 127 | } | ||
127 | } | 128 | } | ||
128 | 129 | | |||
130 | QString ConfigValueProvider::windowDecorationsButtonsOrder() const | ||||
131 | { | ||||
132 | kwinConfig->reparseConfiguration(); | ||||
133 | KConfigGroup configGroup = kwinConfig->group(QStringLiteral("org.kde.kdecoration2")); | ||||
134 | QString buttonsOnLeftKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnLeft"), "MS"); | ||||
135 | QString buttonsOnRightKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnRight"), "HIAX"); | ||||
136 | | ||||
137 | QString buttonsOnLeftInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnLeftKdeConfigValue); | ||||
138 | QString buttonsOnRightInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnRightKdeConfigValue); | ||||
139 | | ||||
140 | return buttonsOnLeftInGtkNotation + QStringLiteral(":") + buttonsOnRightInGtkNotation; | ||||
141 | } | ||||
142 | | ||||
129 | QString ConfigValueProvider::toolbarStyleInDesiredNotation(const QString &kdeConfigValue, ConfigValueProvider::ToolbarStyleNotation notation) const | 143 | QString ConfigValueProvider::toolbarStyleInDesiredNotation(const QString &kdeConfigValue, ConfigValueProvider::ToolbarStyleNotation notation) const | ||
130 | { | 144 | { | ||
131 | QStringList toolbarStyles {}; | 145 | QStringList toolbarStyles {}; | ||
132 | if (notation == ToolbarStyleNotation::SettingsIni) { | 146 | if (notation == ToolbarStyleNotation::SettingsIni) { | ||
133 | toolbarStyles.append({ | 147 | toolbarStyles.append({ | ||
134 | QStringLiteral("GTK_TOOLBAR_ICONS"), | 148 | QStringLiteral("GTK_TOOLBAR_ICONS"), | ||
135 | QStringLiteral("GTK_TOOLBAR_TEXT"), | 149 | QStringLiteral("GTK_TOOLBAR_TEXT"), | ||
136 | QStringLiteral("GTK_TOOLBAR_BOTH_HORIZ"), | 150 | QStringLiteral("GTK_TOOLBAR_BOTH_HORIZ"), | ||
Show All 20 Lines | |||||
157 | } else if (kdeConfigValue == QStringLiteral("TextOnly")) { | 171 | } else if (kdeConfigValue == QStringLiteral("TextOnly")) { | ||
158 | return toolbarStyles[1]; | 172 | return toolbarStyles[1]; | ||
159 | } else if (kdeConfigValue == QStringLiteral("TextBesideIcon")) { | 173 | } else if (kdeConfigValue == QStringLiteral("TextBesideIcon")) { | ||
160 | return toolbarStyles[2]; | 174 | return toolbarStyles[2]; | ||
161 | } else { | 175 | } else { | ||
162 | return toolbarStyles[3]; | 176 | return toolbarStyles[3]; | ||
163 | } | 177 | } | ||
164 | } | 178 | } | ||
179 | | ||||
180 | QString ConfigValueProvider::windowDecorationButtonsOrderInGtkNotation(const QString &kdeConfigValue) const | ||||
181 | { | ||||
182 | QString gtkNotation; | ||||
183 | | ||||
184 | for (const QChar &buttonAbbreviation : kdeConfigValue) { | ||||
185 | if (buttonAbbreviation == 'X') { | ||||
186 | gtkNotation += QStringLiteral("close,"); | ||||
187 | } else if (buttonAbbreviation == 'I') { | ||||
188 | gtkNotation += QStringLiteral("minimize,"); | ||||
189 | } else if (buttonAbbreviation == 'A') { | ||||
190 | gtkNotation += QStringLiteral("maximize,"); | ||||
191 | } else if (buttonAbbreviation == 'M') { | ||||
192 | gtkNotation += QStringLiteral("icon,"); | ||||
193 | } | ||||
194 | } | ||||
195 | gtkNotation.chop(1); | ||||
196 | | ||||
197 | return gtkNotation; | ||||
198 | } |