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