Changeset View
Changeset View
Standalone View
Standalone View
kded/configvalueprovider.cpp
Show All 15 Lines | |||||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include <QFont> | 21 | #include <QFont> | ||
22 | #include <QString> | 22 | #include <QString> | ||
23 | #include <QColor> | 23 | #include <QColor> | ||
24 | #include <QMap> | ||||
25 | #include <QList> | ||||
24 | 26 | | |||
25 | #include <KConfig> | 27 | #include <KConfig> | ||
26 | #include <KIconTheme> | 28 | #include <KIconTheme> | ||
27 | #include <KSharedConfig> | 29 | #include <KSharedConfig> | ||
28 | #include <KConfigGroup> | 30 | #include <KConfigGroup> | ||
31 | #include <KColorScheme> | ||||
32 | #include <KColorUtils> | ||||
29 | 33 | | |||
30 | #include "configvalueprovider.h" | 34 | #include "configvalueprovider.h" | ||
31 | 35 | | |||
32 | ConfigValueProvider::ConfigValueProvider() : | 36 | ConfigValueProvider::ConfigValueProvider() : | ||
33 | kdeglobalsConfig(KSharedConfig::openConfig(QStringLiteral("kdeglobals"))), | 37 | kdeglobalsConfig(KSharedConfig::openConfig(QStringLiteral("kdeglobals"))), | ||
34 | inputConfig(KSharedConfig::openConfig(QStringLiteral("kcminputrc"))), | 38 | inputConfig(KSharedConfig::openConfig(QStringLiteral("kcminputrc"))), | ||
35 | kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc"))) | 39 | kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc"))) | ||
36 | { | 40 | { | ||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | 136 | { | |||
137 | 141 | | |||
138 | if (enableAnimations) { | 142 | if (enableAnimations) { | ||
139 | return QStringLiteral("1"); | 143 | return QStringLiteral("1"); | ||
140 | } else { | 144 | } else { | ||
141 | return QStringLiteral("0"); | 145 | return QStringLiteral("0"); | ||
142 | } | 146 | } | ||
143 | } | 147 | } | ||
144 | 148 | | |||
149 | QMap<QString, QColor> ConfigValueProvider::colors() const | ||||
150 | { | ||||
151 | using KCS = KColorScheme; | ||||
152 | | ||||
153 | // Color Schemes Collection | ||||
154 | QHash<QString, QHash<QString, KCS>> csc { | ||||
155 | {QStringLiteral("active"), { | ||||
156 | {QStringLiteral("view"), KCS(QPalette::Active, KCS::View)}, | ||||
157 | {QStringLiteral("window"), KCS(QPalette::Active, KCS::Window)}, | ||||
158 | {QStringLiteral("button"), KCS(QPalette::Active, KCS::Button)}, | ||||
159 | {QStringLiteral("selection"), KCS(QPalette::Active, KCS::Selection)}, | ||||
160 | {QStringLiteral("tooltip"), KCS(QPalette::Active, KCS::Tooltip)}, | ||||
161 | {QStringLiteral("complementary"), KCS(QPalette::Active, KCS::Complementary)}, | ||||
162 | }}, | ||||
163 | {QStringLiteral("inactive"), { | ||||
164 | {QStringLiteral("view"), KCS(QPalette::Inactive, KCS::View)}, | ||||
165 | {QStringLiteral("window"), KCS(QPalette::Inactive, KCS::Window)}, | ||||
166 | {QStringLiteral("button"), KCS(QPalette::Inactive, KCS::Button)}, | ||||
167 | {QStringLiteral("selection"), KCS(QPalette::Inactive, KCS::Selection)}, | ||||
168 | {QStringLiteral("tooltip"), KCS(QPalette::Inactive, KCS::Tooltip)}, | ||||
169 | {QStringLiteral("complementary"), KCS(QPalette::Inactive, KCS::Complementary)}, | ||||
170 | }}, | ||||
171 | {QStringLiteral("inactive"), { | ||||
172 | {QStringLiteral("view"), KCS(QPalette::Disabled, KCS::View)}, | ||||
173 | {QStringLiteral("window"), KCS(QPalette::Disabled, KCS::Window)}, | ||||
174 | {QStringLiteral("button"), KCS(QPalette::Disabled, KCS::Button)}, | ||||
175 | {QStringLiteral("selection"), KCS(QPalette::Disabled, KCS::Selection)}, | ||||
176 | {QStringLiteral("tooltip"), KCS(QPalette::Disabled, KCS::Tooltip)}, | ||||
177 | {QStringLiteral("complementary"), KCS(QPalette::Disabled, KCS::Complementary)}, | ||||
178 | }}, | ||||
179 | }; | ||||
180 | | ||||
181 | // Color mixing | ||||
182 | QColor windowForegroundColor = csc["active"]["window"].foreground(KCS::NormalText).color(); | ||||
183 | QColor windowBackgroundColor = csc["active"]["window"].background(KCS::NormalBackground).color(); | ||||
184 | QColor bordersColor = KColorUtils::mix(windowBackgroundColor, windowForegroundColor, 0.25); | ||||
185 | | ||||
186 | QColor inactiveWindowForegroundColor = csc["inactive"]["window"].foreground(KCS::NormalText).color(); | ||||
187 | QColor inactiveWindowBackgroundColor = csc["inactive"]["window"].background(KCS::NormalBackground).color(); | ||||
188 | QColor inactiveBordersColor = KColorUtils::mix(inactiveWindowBackgroundColor, inactiveWindowForegroundColor, 0.25); | ||||
189 | | ||||
190 | QColor disabledWindowForegroundColor = csc["disabled"]["window"].foreground(KCS::NormalText).color(); | ||||
191 | QColor disabledWindowBackgroundColor = csc["disabled"]["window"].background(KCS::NormalBackground).color(); | ||||
192 | QColor disabledBordersColor = KColorUtils::mix(disabledWindowBackgroundColor, disabledWindowForegroundColor, 0.25); | ||||
193 | | ||||
194 | QColor unfocusedDisabledWindowForegroundColor = csc["disabled"]["window"].foreground(KCS::NormalText).color(); | ||||
195 | QColor unfocusedDisabledWindowBackgroundColor = csc["disabled"]["window"].background(KCS::NormalBackground).color(); | ||||
196 | QColor unfocusedDisabledBordersColor = KColorUtils::mix(unfocusedDisabledWindowBackgroundColor, unfocusedDisabledWindowForegroundColor, 0.25); | ||||
197 | | ||||
198 | QColor tooltipForegroundColor = csc["active"]["tooltip"].foreground(KCS::NormalText).color(); | ||||
199 | QColor tooltipBackgroundColor = csc["active"]["tooltip"].background(KCS::NormalBackground).color(); | ||||
200 | QColor tooltipBorderColor = KColorUtils::mix(tooltipBackgroundColor, tooltipForegroundColor, 0.25); | ||||
201 | | ||||
202 | KConfigGroup windowManagerConfig = kdeglobalsConfig->group(QStringLiteral("WM")); | ||||
203 | | ||||
204 | return { | ||||
205 | /* | ||||
206 | * Normal (Non Backdrop, Non Insensitive) | ||||
207 | */ | ||||
208 | | ||||
209 | // General Colors | ||||
210 | { "theme_fg_color_breeze", csc["active"]["window"].foreground(KCS::NormalText).color()}, | ||||
211 | { "theme_bg_color_breeze", csc["active"]["window"].background(KCS::NormalBackground).color()}, | ||||
212 | { "theme_text_color_breeze", csc["active"]["view"].foreground(KCS::NormalText).color()}, | ||||
213 | { "theme_base_color_breeze", csc["active"]["view"].background(KCS::NormalBackground).color()}, | ||||
214 | { "theme_view_hover_decoration_color_breeze", csc["active"]["view"].decoration(KCS::HoverColor).color()}, | ||||
215 | { "theme_hovering_selected_bg_color_breeze", csc["active"]["selection"].decoration(KCS::HoverColor).color()}, | ||||
216 | { "theme_selected_bg_color_breeze", csc["active"]["selection"].background(KCS::NormalBackground).color()}, | ||||
217 | { "theme_selected_fg_color_breeze", csc["active"]["selection"].foreground(KCS::NormalText).color()}, | ||||
218 | { "theme_view_active_decoration_color_breeze", csc["active"]["view"].decoration(KCS::HoverColor).color()}, | ||||
219 | | ||||
220 | // Button Colors | ||||
221 | { "theme_button_background_normal_breeze", csc["active"]["button"].background(KCS::NormalBackground).color()}, | ||||
222 | { "theme_button_decoration_hover_breeze", csc["active"]["button"].decoration(KCS::HoverColor).color()}, | ||||
223 | { "theme_button_decoration_focus_breeze", csc["active"]["button"].decoration(KCS::FocusColor).color()}, | ||||
224 | { "theme_button_foreground_normal_breeze", csc["active"]["button"].foreground(KCS::NormalText).color()}, | ||||
225 | { "theme_button_foreground_active_breeze", csc["active"]["selection"].foreground(KCS::NormalText).color()}, | ||||
226 | | ||||
227 | | ||||
228 | // Misc Colors | ||||
229 | { "borders_breeze", bordersColor}, | ||||
230 | { "warning_color_breeze", csc["active"]["view"].foreground(KCS::NeutralText).color()}, | ||||
231 | { "success_color_breeze", csc["active"]["view"].foreground(KCS::PositiveText).color()}, | ||||
232 | { "error_color_breeze", csc["active"]["view"].foreground(KCS::NegativeText).color()}, | ||||
233 | | ||||
234 | /* | ||||
235 | * Backdrop (Inactive) | ||||
236 | */ | ||||
237 | | ||||
238 | // General | ||||
239 | { "theme_unfocused_fg_color_breeze", csc["inactive"]["window"].foreground(KCS::NormalText).color()}, | ||||
240 | { "theme_unfocused_text_color_breeze", csc["inactive"]["view"].foreground(KCS::NormalText).color()}, | ||||
241 | { "theme_unfocused_bg_color_breeze", csc["inactive"]["window"].background(KCS::NormalBackground).color()}, | ||||
242 | { "theme_unfocused_base_color_breeze", csc["inactive"]["view"].background(KCS::NormalBackground).color()}, | ||||
243 | { "theme_unfocused_selected_bg_color_alt_breeze", csc["inactive"]["selection"].background(KCS::NormalBackground).color()}, | ||||
244 | { "theme_unfocused_selected_bg_color_breeze", csc["inactive"]["selection"].background(KCS::NormalBackground).color()}, | ||||
245 | { "theme_unfocused_selected_fg_color_breeze", csc["inactive"]["selection"].foreground(KCS::NormalText).color()}, | ||||
246 | | ||||
247 | // Button | ||||
248 | { "theme_button_background_backdrop_breeze", csc["inactive"]["button"].background(KCS::NormalBackground).color()}, | ||||
249 | { "theme_button_decoration_hover_backdrop_breeze", csc["inactive"]["button"].decoration(KCS::HoverColor).color()}, | ||||
250 | { "theme_button_decoration_focus_backdrop_breeze", csc["inactive"]["button"].decoration(KCS::FocusColor).color()}, | ||||
251 | { "theme_button_foreground_backdrop_breeze", csc["inactive"]["button"].foreground(KCS::NormalText).color()}, | ||||
252 | { "theme_button_foreground_active_backdrop_breeze", csc["inactive"]["selection"].foreground(KCS::NormalText).color()}, | ||||
253 | | ||||
254 | // Misc Colors | ||||
255 | { "unfocused_borders_breeze", inactiveBordersColor}, | ||||
256 | { "warning_color_backdrop_breeze", csc["inactive"]["view"].foreground(KCS::NeutralText).color()}, | ||||
257 | { "success_color_backdrop_breeze", csc["inactive"]["view"].foreground(KCS::PositiveText).color()}, | ||||
258 | { "error_color_backdrop_breeze", csc["inactive"]["view"].foreground(KCS::NegativeText).color()}, | ||||
259 | | ||||
260 | /* | ||||
261 | * Insensitive (Disabled) | ||||
262 | */ | ||||
263 | | ||||
264 | // General | ||||
265 | { "insensitive_fg_color_breeze",csc["disabled"]["window"].foreground(KCS::NormalText).color()}, | ||||
266 | { "insensitive_base_fg_color_breeze", csc["disabled"]["view"].foreground(KCS::NormalText).color()}, | ||||
267 | { "insensitive_bg_color_breeze", csc["disabled"]["window"].background(KCS::NormalBackground).color()}, | ||||
268 | { "insensitive_base_color_breeze", csc["disabled"]["view"].background(KCS::NormalBackground).color()}, | ||||
269 | { "insensitive_selected_bg_color_breeze", csc["disabled"]["selection"].background(KCS::NormalBackground).color()}, | ||||
270 | { "insensitive_selected_fg_color_breeze", csc["disabled"]["selection"].foreground(KCS::NormalText).color()}, | ||||
271 | | ||||
272 | // Button | ||||
273 | { "theme_button_background_insensitive_breeze", csc["disabled"]["button"].background(KCS::NormalBackground).color()}, | ||||
274 | { "theme_button_decoration_hover_insensitive_breeze", csc["disabled"]["button"].decoration(KCS::HoverColor).color()}, | ||||
275 | { "theme_button_decoration_focus_insensitive_breeze", csc["disabled"]["button"].decoration(KCS::FocusColor).color()}, | ||||
276 | { "theme_button_foreground_insensitive_breeze", csc["disabled"]["button"].foreground(KCS::NormalText).color()}, | ||||
277 | { "theme_button_foreground_active_insensitive_breeze", csc["disabled"]["selection"].foreground(KCS::NormalText).color()}, | ||||
278 | | ||||
279 | // Misc Colors | ||||
280 | { "insensitive_borders_breeze", disabledBordersColor}, | ||||
281 | { "warning_color_insensitive_breeze", csc["disabled"]["view"].foreground(KCS::NeutralText).color()}, | ||||
282 | { "success_color_insensitive_breeze", csc["disabled"]["view"].foreground(KCS::PositiveText).color()}, | ||||
283 | { "error_color_insensitive_breeze", csc["disabled"]["view"].foreground(KCS::NegativeText).color()}, | ||||
284 | | ||||
285 | /* | ||||
286 | * Insensitive Backdrop (Inactive Disabled) | ||||
287 | * These pretty much have the same appearance as regular inactive colors, | ||||
288 | * but they're separate in case we decide to make them different in the future. | ||||
289 | */ | ||||
290 | | ||||
291 | // General | ||||
292 | { "insensitive_unfocused_fg_color_breeze",csc["disabled"]["window"].foreground(KCS::NormalText).color()}, | ||||
293 | { "theme_unfocused_view_text_color_breeze", csc["disabled"]["view"].foreground(KCS::NormalText).color()}, | ||||
294 | { "insensitive_unfocused_bg_color_breeze", csc["disabled"]["window"].background(KCS::NormalBackground).color()}, | ||||
295 | { "theme_unfocused_view_bg_color_breeze", csc["disabled"]["view"].background(KCS::NormalBackground).color()}, | ||||
296 | { "insensitive_unfocused_selected_bg_color_breeze", csc["disabled"]["selection"].background(KCS::NormalBackground).color()}, | ||||
297 | { "insensitive_unfocused_selected_fg_color_breeze", csc["disabled"]["selection"].foreground(KCS::NormalText).color()}, | ||||
298 | | ||||
299 | // Button | ||||
300 | { "theme_button_background_backdrop_insensitive_breeze", csc["disabled"]["button"].background(KCS::NormalBackground).color()}, | ||||
301 | { "theme_button_decoration_hover_backdrop_insensitive_breeze", csc["disabled"]["button"].decoration(KCS::HoverColor).color()}, | ||||
302 | { "theme_button_decoration_focus_backdrop_insensitive_breeze", csc["disabled"]["button"].decoration(KCS::FocusColor).color()}, | ||||
303 | { "theme_button_foreground_backdrop_insensitive_breeze", csc["disabled"]["button"].foreground(KCS::NormalText).color()}, | ||||
304 | { "theme_button_foreground_active_backdrop_insensitive_breeze", csc["disabled"]["selection"].foreground(KCS::NormalText).color()}, | ||||
305 | | ||||
306 | // Misc Colors | ||||
307 | { "unfocused_insensitive_borders_breeze", unfocusedDisabledBordersColor}, | ||||
308 | { "warning_color_insensitive_backdrop_breeze", csc["disabled"]["view"].foreground(KCS::NeutralText).color()}, | ||||
309 | { "success_color_insensitive_backdrop_breeze", csc["disabled"]["view"].foreground(KCS::PositiveText).color()}, | ||||
310 | { "error_color_insensitive_backdrop_breeze", csc["disabled"]["view"].foreground(KCS::NegativeText).color()}, | ||||
311 | | ||||
312 | /* | ||||
313 | * Ignorant Colors (These colors do not care about backdrop or insensitive states) | ||||
314 | */ | ||||
315 | | ||||
316 | { "link_color_breeze", csc["active"]["view"].foreground(KCS::LinkText).color()}, | ||||
317 | { "link_visited_color_breeze", csc["active"]["view"].foreground(KCS::VisitedText).color()}, | ||||
318 | | ||||
319 | { "tooltip_text_breeze", tooltipForegroundColor}, | ||||
320 | { "tooltip_background_breeze", tooltipBackgroundColor}, | ||||
321 | { "tooltip_border_breeze", tooltipBorderColor}, | ||||
322 | | ||||
323 | { "content_view_bg_breeze", csc["active"]["view"].background(KCS::NormalBackground).color()}, | ||||
324 | | ||||
325 | { "theme_titlebar_background_breeze", windowManagerConfig.readEntry("activeBackground", QColor())}, | ||||
326 | { "theme_titlebar_foreground_breeze", windowManagerConfig.readEntry("activeForeground", QColor())}, | ||||
327 | { "theme_titlebar_background_light_breeze", csc["active"]["window"].background(KCS::NormalBackground).color()}, | ||||
328 | { "theme_titlebar_foreground_backdrop_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
329 | { "theme_titlebar_background_backdrop_breeze", windowManagerConfig.readEntry("inactiveBackground", QColor())}, | ||||
330 | { "theme_titlebar_foreground_insensitive_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
331 | { "theme_titlebar_foreground_insensitive_backdrop_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
332 | | ||||
333 | // Titlebar colors | ||||
334 | { "theme_titlebar_background_breeze", windowManagerConfig.readEntry("activeBackground", QColor())}, | ||||
335 | { "theme_titlebar_foreground_breeze", windowManagerConfig.readEntry("activeForeground", QColor())}, | ||||
336 | { "theme_titlebar_background_light_breeze", csc["active"]["window"].background(KCS::NormalBackground).color()}, | ||||
337 | { "theme_titlebar_foreground_backdrop_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
338 | { "theme_titlebar_background_backdrop_breeze", windowManagerConfig.readEntry("inactiveBackground", QColor())}, | ||||
339 | { "theme_titlebar_foreground_insensitive_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
340 | { "theme_titlebar_foreground_insensitive_backdrop_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
341 | }; | ||||
342 | } | ||||
343 | | ||||
145 | QString ConfigValueProvider::toolbarStyleInDesiredNotation(const QString &kdeConfigValue, ConfigValueProvider::ToolbarStyleNotation notation) const | 344 | QString ConfigValueProvider::toolbarStyleInDesiredNotation(const QString &kdeConfigValue, ConfigValueProvider::ToolbarStyleNotation notation) const | ||
146 | { | 345 | { | ||
147 | QStringList toolbarStyles {}; | 346 | QStringList toolbarStyles {}; | ||
148 | if (notation == ToolbarStyleNotation::SettingsIni) { | 347 | if (notation == ToolbarStyleNotation::SettingsIni) { | ||
149 | toolbarStyles.append({ | 348 | toolbarStyles.append({ | ||
150 | QStringLiteral("GTK_TOOLBAR_ICONS"), | 349 | QStringLiteral("GTK_TOOLBAR_ICONS"), | ||
151 | QStringLiteral("GTK_TOOLBAR_TEXT"), | 350 | QStringLiteral("GTK_TOOLBAR_TEXT"), | ||
152 | QStringLiteral("GTK_TOOLBAR_BOTH_HORIZ"), | 351 | QStringLiteral("GTK_TOOLBAR_BOTH_HORIZ"), | ||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |