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 163 Lines • ▼ Show 20 Line(s) | 199 | { | |||
200 | 204 | | |||
201 | if (enableAnimations) { | 205 | if (enableAnimations) { | ||
202 | return QStringLiteral("1"); | 206 | return QStringLiteral("1"); | ||
203 | } else { | 207 | } else { | ||
204 | return QStringLiteral("0"); | 208 | return QStringLiteral("0"); | ||
205 | } | 209 | } | ||
206 | } | 210 | } | ||
207 | 211 | | |||
212 | QMap<QString, QColor> ConfigValueProvider::colors() const | ||||
213 | { | ||||
214 | using KCS = KColorScheme; | ||||
215 | | ||||
216 | // Color Schemes Collection | ||||
217 | QHash<QString, QHash<QString, KCS>> csc { | ||||
218 | {QStringLiteral("active"), { | ||||
219 | {QStringLiteral("view"), KCS(QPalette::Active, KCS::View)}, | ||||
220 | {QStringLiteral("window"), KCS(QPalette::Active, KCS::Window)}, | ||||
221 | {QStringLiteral("button"), KCS(QPalette::Active, KCS::Button)}, | ||||
222 | {QStringLiteral("selection"), KCS(QPalette::Active, KCS::Selection)}, | ||||
223 | {QStringLiteral("tooltip"), KCS(QPalette::Active, KCS::Tooltip)}, | ||||
224 | {QStringLiteral("complementary"), KCS(QPalette::Active, KCS::Complementary)}, | ||||
225 | }}, | ||||
226 | {QStringLiteral("inactive"), { | ||||
227 | {QStringLiteral("view"), KCS(QPalette::Inactive, KCS::View)}, | ||||
228 | {QStringLiteral("window"), KCS(QPalette::Inactive, KCS::Window)}, | ||||
229 | {QStringLiteral("button"), KCS(QPalette::Inactive, KCS::Button)}, | ||||
230 | {QStringLiteral("selection"), KCS(QPalette::Inactive, KCS::Selection)}, | ||||
231 | {QStringLiteral("tooltip"), KCS(QPalette::Inactive, KCS::Tooltip)}, | ||||
232 | {QStringLiteral("complementary"), KCS(QPalette::Inactive, KCS::Complementary)}, | ||||
233 | }}, | ||||
234 | {QStringLiteral("inactive"), { | ||||
235 | {QStringLiteral("view"), KCS(QPalette::Disabled, KCS::View)}, | ||||
236 | {QStringLiteral("window"), KCS(QPalette::Disabled, KCS::Window)}, | ||||
237 | {QStringLiteral("button"), KCS(QPalette::Disabled, KCS::Button)}, | ||||
238 | {QStringLiteral("selection"), KCS(QPalette::Disabled, KCS::Selection)}, | ||||
239 | {QStringLiteral("tooltip"), KCS(QPalette::Disabled, KCS::Tooltip)}, | ||||
240 | {QStringLiteral("complementary"), KCS(QPalette::Disabled, KCS::Complementary)}, | ||||
241 | }}, | ||||
242 | }; | ||||
243 | | ||||
244 | // Color mixing | ||||
245 | QColor windowForegroundColor = csc["active"]["window"].foreground(KCS::NormalText).color(); | ||||
246 | QColor windowBackgroundColor = csc["active"]["window"].background(KCS::NormalBackground).color(); | ||||
247 | QColor bordersColor = KColorUtils::mix(windowBackgroundColor, windowForegroundColor, 0.25); | ||||
248 | | ||||
249 | QColor inactiveWindowForegroundColor = csc["inactive"]["window"].foreground(KCS::NormalText).color(); | ||||
250 | QColor inactiveWindowBackgroundColor = csc["inactive"]["window"].background(KCS::NormalBackground).color(); | ||||
251 | QColor inactiveBordersColor = KColorUtils::mix(inactiveWindowBackgroundColor, inactiveWindowForegroundColor, 0.25); | ||||
252 | | ||||
253 | QColor disabledWindowForegroundColor = csc["disabled"]["window"].foreground(KCS::NormalText).color(); | ||||
254 | QColor disabledWindowBackgroundColor = csc["disabled"]["window"].background(KCS::NormalBackground).color(); | ||||
255 | QColor disabledBordersColor = KColorUtils::mix(disabledWindowBackgroundColor, disabledWindowForegroundColor, 0.25); | ||||
256 | | ||||
257 | QColor unfocusedDisabledWindowForegroundColor = csc["disabled"]["window"].foreground(KCS::NormalText).color(); | ||||
258 | QColor unfocusedDisabledWindowBackgroundColor = csc["disabled"]["window"].background(KCS::NormalBackground).color(); | ||||
259 | QColor unfocusedDisabledBordersColor = KColorUtils::mix(unfocusedDisabledWindowBackgroundColor, unfocusedDisabledWindowForegroundColor, 0.25); | ||||
260 | | ||||
261 | QColor tooltipForegroundColor = csc["active"]["tooltip"].foreground(KCS::NormalText).color(); | ||||
262 | QColor tooltipBackgroundColor = csc["active"]["tooltip"].background(KCS::NormalBackground).color(); | ||||
263 | QColor tooltipBorderColor = KColorUtils::mix(tooltipBackgroundColor, tooltipForegroundColor, 0.25); | ||||
264 | | ||||
265 | KConfigGroup windowManagerConfig = kdeglobalsConfig->group(QStringLiteral("WM")); | ||||
266 | | ||||
267 | return { | ||||
268 | /* | ||||
269 | * Normal (Non Backdrop, Non Insensitive) | ||||
270 | */ | ||||
271 | | ||||
272 | // General Colors | ||||
273 | { "theme_fg_color_breeze", csc["active"]["window"].foreground(KCS::NormalText).color()}, | ||||
274 | { "theme_bg_color_breeze", csc["active"]["window"].background(KCS::NormalBackground).color()}, | ||||
275 | { "theme_text_color_breeze", csc["active"]["view"].foreground(KCS::NormalText).color()}, | ||||
276 | { "theme_base_color_breeze", csc["active"]["view"].background(KCS::NormalBackground).color()}, | ||||
277 | { "theme_view_hover_decoration_color_breeze", csc["active"]["view"].decoration(KCS::HoverColor).color()}, | ||||
278 | { "theme_hovering_selected_bg_color_breeze", csc["active"]["selection"].decoration(KCS::HoverColor).color()}, | ||||
279 | { "theme_selected_bg_color_breeze", csc["active"]["selection"].background(KCS::NormalBackground).color()}, | ||||
280 | { "theme_selected_fg_color_breeze", csc["active"]["selection"].foreground(KCS::NormalText).color()}, | ||||
281 | { "theme_view_active_decoration_color_breeze", csc["active"]["view"].decoration(KCS::HoverColor).color()}, | ||||
282 | | ||||
283 | // Button Colors | ||||
284 | { "theme_button_background_normal_breeze", csc["active"]["button"].background(KCS::NormalBackground).color()}, | ||||
285 | { "theme_button_decoration_hover_breeze", csc["active"]["button"].decoration(KCS::HoverColor).color()}, | ||||
286 | { "theme_button_decoration_focus_breeze", csc["active"]["button"].decoration(KCS::FocusColor).color()}, | ||||
287 | { "theme_button_foreground_normal_breeze", csc["active"]["button"].foreground(KCS::NormalText).color()}, | ||||
288 | { "theme_button_foreground_active_breeze", csc["active"]["selection"].foreground(KCS::NormalText).color()}, | ||||
289 | | ||||
290 | | ||||
291 | // Misc Colors | ||||
292 | { "borders_breeze", bordersColor}, | ||||
293 | { "warning_color_breeze", csc["active"]["view"].foreground(KCS::NeutralText).color()}, | ||||
294 | { "success_color_breeze", csc["active"]["view"].foreground(KCS::PositiveText).color()}, | ||||
295 | { "error_color_breeze", csc["active"]["view"].foreground(KCS::NegativeText).color()}, | ||||
296 | | ||||
297 | /* | ||||
298 | * Backdrop (Inactive) | ||||
299 | */ | ||||
300 | | ||||
301 | // General | ||||
302 | { "theme_unfocused_fg_color_breeze", csc["inactive"]["window"].foreground(KCS::NormalText).color()}, | ||||
303 | { "theme_unfocused_text_color_breeze", csc["inactive"]["view"].foreground(KCS::NormalText).color()}, | ||||
304 | { "theme_unfocused_bg_color_breeze", csc["inactive"]["window"].background(KCS::NormalBackground).color()}, | ||||
305 | { "theme_unfocused_base_color_breeze", csc["inactive"]["view"].background(KCS::NormalBackground).color()}, | ||||
306 | { "theme_unfocused_selected_bg_color_alt_breeze", csc["inactive"]["selection"].background(KCS::NormalBackground).color()}, | ||||
307 | { "theme_unfocused_selected_bg_color_breeze", csc["inactive"]["selection"].background(KCS::NormalBackground).color()}, | ||||
308 | { "theme_unfocused_selected_fg_color_breeze", csc["inactive"]["selection"].foreground(KCS::NormalText).color()}, | ||||
309 | | ||||
310 | // Button | ||||
311 | { "theme_button_background_backdrop_breeze", csc["inactive"]["button"].background(KCS::NormalBackground).color()}, | ||||
312 | { "theme_button_decoration_hover_backdrop_breeze", csc["inactive"]["button"].decoration(KCS::HoverColor).color()}, | ||||
313 | { "theme_button_decoration_focus_backdrop_breeze", csc["inactive"]["button"].decoration(KCS::FocusColor).color()}, | ||||
314 | { "theme_button_foreground_backdrop_breeze", csc["inactive"]["button"].foreground(KCS::NormalText).color()}, | ||||
315 | { "theme_button_foreground_active_backdrop_breeze", csc["inactive"]["selection"].foreground(KCS::NormalText).color()}, | ||||
316 | | ||||
317 | // Misc Colors | ||||
318 | { "unfocused_borders_breeze", inactiveBordersColor}, | ||||
319 | { "warning_color_backdrop_breeze", csc["inactive"]["view"].foreground(KCS::NeutralText).color()}, | ||||
320 | { "success_color_backdrop_breeze", csc["inactive"]["view"].foreground(KCS::PositiveText).color()}, | ||||
321 | { "error_color_backdrop_breeze", csc["inactive"]["view"].foreground(KCS::NegativeText).color()}, | ||||
322 | | ||||
323 | /* | ||||
324 | * Insensitive (Disabled) | ||||
325 | */ | ||||
326 | | ||||
327 | // General | ||||
328 | { "insensitive_fg_color_breeze",csc["disabled"]["window"].foreground(KCS::NormalText).color()}, | ||||
329 | { "insensitive_base_fg_color_breeze", csc["disabled"]["view"].foreground(KCS::NormalText).color()}, | ||||
330 | { "insensitive_bg_color_breeze", csc["disabled"]["window"].background(KCS::NormalBackground).color()}, | ||||
331 | { "insensitive_base_color_breeze", csc["disabled"]["view"].background(KCS::NormalBackground).color()}, | ||||
332 | { "insensitive_selected_bg_color_breeze", csc["disabled"]["selection"].background(KCS::NormalBackground).color()}, | ||||
333 | { "insensitive_selected_fg_color_breeze", csc["disabled"]["selection"].foreground(KCS::NormalText).color()}, | ||||
334 | | ||||
335 | // Button | ||||
336 | { "theme_button_background_insensitive_breeze", csc["disabled"]["button"].background(KCS::NormalBackground).color()}, | ||||
337 | { "theme_button_decoration_hover_insensitive_breeze", csc["disabled"]["button"].decoration(KCS::HoverColor).color()}, | ||||
338 | { "theme_button_decoration_focus_insensitive_breeze", csc["disabled"]["button"].decoration(KCS::FocusColor).color()}, | ||||
339 | { "theme_button_foreground_insensitive_breeze", csc["disabled"]["button"].foreground(KCS::NormalText).color()}, | ||||
340 | { "theme_button_foreground_active_insensitive_breeze", csc["disabled"]["selection"].foreground(KCS::NormalText).color()}, | ||||
341 | | ||||
342 | // Misc Colors | ||||
343 | { "insensitive_borders_breeze", disabledBordersColor}, | ||||
344 | { "warning_color_insensitive_breeze", csc["disabled"]["view"].foreground(KCS::NeutralText).color()}, | ||||
345 | { "success_color_insensitive_breeze", csc["disabled"]["view"].foreground(KCS::PositiveText).color()}, | ||||
346 | { "error_color_insensitive_breeze", csc["disabled"]["view"].foreground(KCS::NegativeText).color()}, | ||||
347 | | ||||
348 | /* | ||||
349 | * Insensitive Backdrop (Inactive Disabled) | ||||
350 | * These pretty much have the same appearance as regular inactive colors, | ||||
351 | * but they're separate in case we decide to make them different in the future. | ||||
352 | */ | ||||
353 | | ||||
354 | // General | ||||
355 | { "insensitive_unfocused_fg_color_breeze",csc["disabled"]["window"].foreground(KCS::NormalText).color()}, | ||||
356 | { "theme_unfocused_view_text_color_breeze", csc["disabled"]["view"].foreground(KCS::NormalText).color()}, | ||||
357 | { "insensitive_unfocused_bg_color_breeze", csc["disabled"]["window"].background(KCS::NormalBackground).color()}, | ||||
358 | { "theme_unfocused_view_bg_color_breeze", csc["disabled"]["view"].background(KCS::NormalBackground).color()}, | ||||
359 | { "insensitive_unfocused_selected_bg_color_breeze", csc["disabled"]["selection"].background(KCS::NormalBackground).color()}, | ||||
360 | { "insensitive_unfocused_selected_fg_color_breeze", csc["disabled"]["selection"].foreground(KCS::NormalText).color()}, | ||||
361 | | ||||
362 | // Button | ||||
363 | { "theme_button_background_backdrop_insensitive_breeze", csc["disabled"]["button"].background(KCS::NormalBackground).color()}, | ||||
364 | { "theme_button_decoration_hover_backdrop_insensitive_breeze", csc["disabled"]["button"].decoration(KCS::HoverColor).color()}, | ||||
365 | { "theme_button_decoration_focus_backdrop_insensitive_breeze", csc["disabled"]["button"].decoration(KCS::FocusColor).color()}, | ||||
366 | { "theme_button_foreground_backdrop_insensitive_breeze", csc["disabled"]["button"].foreground(KCS::NormalText).color()}, | ||||
367 | { "theme_button_foreground_active_backdrop_insensitive_breeze", csc["disabled"]["selection"].foreground(KCS::NormalText).color()}, | ||||
368 | | ||||
369 | // Misc Colors | ||||
370 | { "unfocused_insensitive_borders_breeze", unfocusedDisabledBordersColor}, | ||||
371 | { "warning_color_insensitive_backdrop_breeze", csc["disabled"]["view"].foreground(KCS::NeutralText).color()}, | ||||
372 | { "success_color_insensitive_backdrop_breeze", csc["disabled"]["view"].foreground(KCS::PositiveText).color()}, | ||||
373 | { "error_color_insensitive_backdrop_breeze", csc["disabled"]["view"].foreground(KCS::NegativeText).color()}, | ||||
374 | | ||||
375 | /* | ||||
376 | * Ignorant Colors (These colors do not care about backdrop or insensitive states) | ||||
377 | */ | ||||
378 | | ||||
379 | { "link_color_breeze", csc["active"]["view"].foreground(KCS::LinkText).color()}, | ||||
380 | { "link_visited_color_breeze", csc["active"]["view"].foreground(KCS::VisitedText).color()}, | ||||
381 | | ||||
382 | { "tooltip_text_breeze", tooltipForegroundColor}, | ||||
383 | { "tooltip_background_breeze", tooltipBackgroundColor}, | ||||
384 | { "tooltip_border_breeze", tooltipBorderColor}, | ||||
385 | | ||||
386 | { "content_view_bg_breeze", csc["active"]["view"].background(KCS::NormalBackground).color()}, | ||||
387 | | ||||
388 | { "theme_titlebar_background_breeze", windowManagerConfig.readEntry("activeBackground", QColor())}, | ||||
389 | { "theme_titlebar_foreground_breeze", windowManagerConfig.readEntry("activeForeground", QColor())}, | ||||
390 | { "theme_titlebar_background_light_breeze", csc["active"]["window"].background(KCS::NormalBackground).color()}, | ||||
391 | { "theme_titlebar_foreground_backdrop_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
392 | { "theme_titlebar_background_backdrop_breeze", windowManagerConfig.readEntry("inactiveBackground", QColor())}, | ||||
393 | { "theme_titlebar_foreground_insensitive_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
394 | { "theme_titlebar_foreground_insensitive_backdrop_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
395 | | ||||
396 | // Titlebar colors | ||||
397 | { "theme_titlebar_background_breeze", windowManagerConfig.readEntry("activeBackground", QColor())}, | ||||
398 | { "theme_titlebar_foreground_breeze", windowManagerConfig.readEntry("activeForeground", QColor())}, | ||||
399 | { "theme_titlebar_background_light_breeze", csc["active"]["window"].background(KCS::NormalBackground).color()}, | ||||
400 | { "theme_titlebar_foreground_backdrop_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
401 | { "theme_titlebar_background_backdrop_breeze", windowManagerConfig.readEntry("inactiveBackground", QColor())}, | ||||
402 | { "theme_titlebar_foreground_insensitive_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
403 | { "theme_titlebar_foreground_insensitive_backdrop_breeze", windowManagerConfig.readEntry("inactiveForeground", QColor())}, | ||||
404 | }; | ||||
405 | } | ||||
406 | | ||||
208 | QString ConfigValueProvider::toolbarStyleInDesiredNotation(const QString &kdeConfigValue, ConfigValueProvider::ToolbarStyleNotation notation) const | 407 | QString ConfigValueProvider::toolbarStyleInDesiredNotation(const QString &kdeConfigValue, ConfigValueProvider::ToolbarStyleNotation notation) const | ||
209 | { | 408 | { | ||
210 | QStringList toolbarStyles {}; | 409 | QStringList toolbarStyles {}; | ||
211 | if (notation == ToolbarStyleNotation::SettingsIni) { | 410 | if (notation == ToolbarStyleNotation::SettingsIni) { | ||
212 | toolbarStyles.append({ | 411 | toolbarStyles.append({ | ||
213 | QStringLiteral("GTK_TOOLBAR_ICONS"), | 412 | QStringLiteral("GTK_TOOLBAR_ICONS"), | ||
214 | QStringLiteral("GTK_TOOLBAR_TEXT"), | 413 | QStringLiteral("GTK_TOOLBAR_TEXT"), | ||
215 | QStringLiteral("GTK_TOOLBAR_BOTH_HORIZ"), | 414 | QStringLiteral("GTK_TOOLBAR_BOTH_HORIZ"), | ||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |