Changeset View
Changeset View
Standalone View
Standalone View
kcms/krdb/krdb.cpp
Show First 20 Lines • Show All 401 Lines • ▼ Show 20 Line(s) | |||||
402 | } | 402 | } | ||
403 | 403 | | |||
404 | // --------------------------------------------------------------------- | 404 | // --------------------------------------------------------------------- | ||
405 | 405 | | |||
406 | QString gtkColorsHelper(const QString &name, const QString &color) | 406 | QString gtkColorsHelper(const QString &name, const QString &color) | ||
407 | { | 407 | { | ||
408 | return QStringLiteral("@define-color %1 %2;\n").arg(name, color); | 408 | return QStringLiteral("@define-color %1 %2;\n").arg(name, color); | ||
409 | } | 409 | } | ||
410 | 410 | void checkGtkCss() | |||
411 | void saveGtkColors() | | |||
412 | { | 411 | { | ||
413 | KConfigGroup g(KSharedConfig::openConfig(), "WM"); | | |||
414 | QFile gtkCss(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/gtk-3.0/gtk.css"); | 412 | QFile gtkCss(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/gtk-3.0/gtk.css"); | ||
415 | QFile colorsCss(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/gtk-3.0/colors.css"); | | |||
416 | | ||||
417 | if (gtkCss.open(QIODevice::ReadWrite)) { | 413 | if (gtkCss.open(QIODevice::ReadWrite)) { | ||
418 | QTextStream gtkStream(>kCss); | 414 | QTextStream gtkStream(>kCss); | ||
419 | bool hasImport = false; | 415 | bool hasImport = false; | ||
420 | while (!gtkStream.atEnd()) { | 416 | while (!gtkStream.atEnd()) { | ||
421 | QString line = gtkStream.readLine(); | 417 | QString line = gtkStream.readLine(); | ||
422 | if (line.contains("@import 'colors.css';")) { | 418 | if (line.contains("@import 'colors.css';")) { | ||
423 | hasImport = true; | 419 | hasImport = true; | ||
424 | } | 420 | } | ||
425 | } | 421 | } | ||
426 | if (!hasImport) { | 422 | if (!hasImport) { | ||
427 | gtkStream << "@import 'colors.css';"; | 423 | gtkStream << "@import 'colors.css';"; | ||
428 | } | 424 | } | ||
429 | } | 425 | } | ||
430 | if (colorsCss.open(QIODevice::WriteOnly | QIODevice::Truncate)) { | 426 | } | ||
431 | QTextStream colorsStream(&colorsCss); | 427 | void exportGtkColors(QList<KColorScheme> activeColorSchemes, QList<KColorScheme> inactiveColorSchemes, QList<KColorScheme> disabledColorSchemes, KConfigGroup groupWMTheme, QTextStream& colorsStream) | ||
432 | /* | 428 | { | ||
433 | 0 Active View | | |||
434 | 1 Active Window | | |||
435 | 2 Active Button | | |||
436 | 3 Active Selection | | |||
437 | 4 Active Tooltip | | |||
438 | 5 Active Complimentary | | |||
439 | */ | | |||
440 | | ||||
441 | QList<KColorScheme> activeColorSchemes{ | | |||
442 | KColorScheme(QPalette::Active, KColorScheme::View), | | |||
443 | KColorScheme(QPalette::Active, KColorScheme::Window), | | |||
444 | KColorScheme(QPalette::Active, KColorScheme::Button), | | |||
445 | KColorScheme(QPalette::Active, KColorScheme::Selection), | | |||
446 | KColorScheme(QPalette::Active, KColorScheme::Tooltip), | | |||
447 | KColorScheme(QPalette::Active, KColorScheme::Complementary) | | |||
448 | }; | | |||
449 | QList<KColorScheme> inactiveColorSchemes{ | | |||
450 | KColorScheme(QPalette::Inactive, KColorScheme::View), | | |||
451 | KColorScheme(QPalette::Inactive, KColorScheme::Window), | | |||
452 | KColorScheme(QPalette::Inactive, KColorScheme::Button), | | |||
453 | KColorScheme(QPalette::Inactive, KColorScheme::Selection), | | |||
454 | KColorScheme(QPalette::Inactive, KColorScheme::Tooltip), | | |||
455 | KColorScheme(QPalette::Inactive, KColorScheme::Complementary) | | |||
456 | }; | | |||
457 | QList<KColorScheme> disabledColorSchemes{ | | |||
458 | KColorScheme(QPalette::Disabled, KColorScheme::View), | | |||
459 | KColorScheme(QPalette::Disabled, KColorScheme::Window), | | |||
460 | KColorScheme(QPalette::Disabled, KColorScheme::Button), | | |||
461 | KColorScheme(QPalette::Disabled, KColorScheme::Selection), | | |||
462 | KColorScheme(QPalette::Disabled, KColorScheme::Tooltip), | | |||
463 | KColorScheme(QPalette::Disabled, KColorScheme::Complementary) | | |||
464 | }; | | |||
465 | | ||||
466 | /* | 429 | /* | ||
467 | Normal (Non Backdrop, Non Insensitive) | 430 | Normal (Non Backdrop, Non Insensitive) | ||
468 | */ | 431 | */ | ||
469 | 432 | | |||
470 | // General Colors | 433 | // General Colors | ||
471 | 434 | | |||
472 | colorsStream << gtkColorsHelper("theme_fg_color", activeColorSchemes[1].foreground(KColorScheme::NormalText).color().name()); | 435 | colorsStream << gtkColorsHelper("theme_fg_color", activeColorSchemes[1].foreground(KColorScheme::NormalText).color().name()); | ||
473 | colorsStream << gtkColorsHelper("theme_bg_color", activeColorSchemes[1].background(KColorScheme::NormalBackground).color().name()); | 436 | colorsStream << gtkColorsHelper("theme_bg_color", activeColorSchemes[1].background(KColorScheme::NormalBackground).color().name()); | ||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | |||||
597 | QColor tooltipBorderColor = KColorUtils::mix(tooltipBackgroundColor, tooltipForegroundColor, 0.25); | 560 | QColor tooltipBorderColor = KColorUtils::mix(tooltipBackgroundColor, tooltipForegroundColor, 0.25); | ||
598 | 561 | | |||
599 | colorsStream << gtkColorsHelper("tooltip_text", tooltipForegroundColor.name()); | 562 | colorsStream << gtkColorsHelper("tooltip_text", tooltipForegroundColor.name()); | ||
600 | colorsStream << gtkColorsHelper("tooltip_background", tooltipBackgroundColor.name()); | 563 | colorsStream << gtkColorsHelper("tooltip_background", tooltipBackgroundColor.name()); | ||
601 | colorsStream << gtkColorsHelper("tooltip_border", tooltipBorderColor.name()); | 564 | colorsStream << gtkColorsHelper("tooltip_border", tooltipBorderColor.name()); | ||
602 | 565 | | |||
603 | colorsStream << gtkColorsHelper("content_view_bg", activeColorSchemes[0].background(KColorScheme::NormalBackground).color().name()); | 566 | colorsStream << gtkColorsHelper("content_view_bg", activeColorSchemes[0].background(KColorScheme::NormalBackground).color().name()); | ||
604 | 567 | | |||
568 | // Titlebar colors | ||||
569 | colorsStream << gtkColorsHelper("theme_titlebar_background", "rgb(" + groupWMTheme.readEntry("activeBackground", "") + ")"); | ||||
570 | colorsStream << gtkColorsHelper("theme_titlebar_foreground", "rgb(" + groupWMTheme.readEntry("activeForeground", "") + ")"); | ||||
571 | colorsStream << gtkColorsHelper("theme_titlebar_background_light", activeColorSchemes[1].background(KColorScheme::NormalBackground).color().name()); | ||||
572 | colorsStream << gtkColorsHelper("theme_titlebar_foreground_backdrop", "rgb(" + groupWMTheme.readEntry("inactiveForeground", "") + ")"); | ||||
573 | colorsStream << gtkColorsHelper("theme_titlebar_background_backdrop", "rgb(" + groupWMTheme.readEntry("inactiveBackground", "") + ")"); | ||||
574 | colorsStream << gtkColorsHelper("theme_titlebar_foreground_insensitive", "rgb(" + groupWMTheme.readEntry("inactiveForeground", "") + ")"); | ||||
575 | colorsStream << gtkColorsHelper("theme_titlebar_foreground_insensitive_backdrop", "rgb(" + groupWMTheme.readEntry("inactiveForeground", "") + ")"); | ||||
576 | } | ||||
577 | void saveGtkColors(KSharedConfigPtr& config) | ||||
578 | { | ||||
579 | checkGtkCss(); | ||||
580 | QFile colorsCss(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/gtk-3.0/colors.css"); | ||||
581 | | ||||
582 | if (colorsCss.open(QIODevice::WriteOnly | QIODevice::Truncate)) { | ||||
583 | QTextStream colorsStream(&colorsCss); | ||||
584 | /* | ||||
585 | 0 Active View | ||||
586 | 1 Active Window | ||||
587 | 2 Active Button | ||||
588 | 3 Active Selection | ||||
589 | 4 Active Tooltip | ||||
590 | 5 Active Complimentary | ||||
591 | */ | ||||
592 | | ||||
593 | QList<KColorScheme> activeColorSchemes{ | ||||
594 | KColorScheme(QPalette::Active, KColorScheme::View, config), | ||||
595 | KColorScheme(QPalette::Active, KColorScheme::Window, config), | ||||
596 | KColorScheme(QPalette::Active, KColorScheme::Button, config), | ||||
597 | KColorScheme(QPalette::Active, KColorScheme::Selection, config), | ||||
598 | KColorScheme(QPalette::Active, KColorScheme::Tooltip, config), | ||||
599 | KColorScheme(QPalette::Active, KColorScheme::Complementary, config) | ||||
600 | }; | ||||
601 | QList<KColorScheme> inactiveColorSchemes{ | ||||
602 | KColorScheme(QPalette::Inactive, KColorScheme::View, config), | ||||
603 | KColorScheme(QPalette::Inactive, KColorScheme::Window, config), | ||||
604 | KColorScheme(QPalette::Inactive, KColorScheme::Button, config), | ||||
605 | KColorScheme(QPalette::Inactive, KColorScheme::Selection, config), | ||||
606 | KColorScheme(QPalette::Inactive, KColorScheme::Tooltip, config), | ||||
607 | KColorScheme(QPalette::Inactive, KColorScheme::Complementary, config) | ||||
608 | }; | ||||
609 | QList<KColorScheme> disabledColorSchemes{ | ||||
610 | KColorScheme(QPalette::Disabled, KColorScheme::View, config), | ||||
611 | KColorScheme(QPalette::Disabled, KColorScheme::Window, config), | ||||
612 | KColorScheme(QPalette::Disabled, KColorScheme::Button, config), | ||||
613 | KColorScheme(QPalette::Disabled, KColorScheme::Selection, config), | ||||
614 | KColorScheme(QPalette::Disabled, KColorScheme::Tooltip, config), | ||||
615 | KColorScheme(QPalette::Disabled, KColorScheme::Complementary, config) | ||||
616 | }; | ||||
617 | KConfigGroup groupWMTheme(config, "WM"); | ||||
618 | exportGtkColors(activeColorSchemes, inactiveColorSchemes, disabledColorSchemes, groupWMTheme, colorsStream); | ||||
619 | } | ||||
620 | } | ||||
621 | | ||||
622 | void saveGtkColors() | ||||
623 | { | ||||
624 | checkGtkCss(); | ||||
625 | QFile colorsCss(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/gtk-3.0/colors.css"); | ||||
626 | KConfigGroup groupWMTheme(KSharedConfig::openConfig(), "WM"); | ||||
627 | | ||||
628 | if (colorsCss.open(QIODevice::WriteOnly | QIODevice::Truncate)) { | ||||
629 | QTextStream colorsStream(&colorsCss); | ||||
605 | /* | 630 | /* | ||
606 | Theme titlebar colors | 631 | 0 Active View | ||
632 | 1 Active Window | ||||
633 | 2 Active Button | ||||
634 | 3 Active Selection | ||||
635 | 4 Active Tooltip | ||||
636 | 5 Active Complimentary | ||||
607 | */ | 637 | */ | ||
608 | colorsStream << gtkColorsHelper("theme_titlebar_background", "rgb(" + g.readEntry("activeBackground", "") + ")"); | 638 | | ||
609 | colorsStream << gtkColorsHelper("theme_titlebar_foreground", "rgb(" + g.readEntry("activeForeground", "") + ")"); | 639 | QList<KColorScheme> activeColorSchemes{ | ||
610 | colorsStream << gtkColorsHelper("theme_titlebar_background_light", activeColorSchemes[1].background(KColorScheme::NormalBackground).color().name()); | 640 | KColorScheme(QPalette::Active, KColorScheme::View), | ||
611 | colorsStream << gtkColorsHelper("theme_titlebar_foreground_backdrop", "rgb(" + g.readEntry("inactiveForeground", "") + ")"); | 641 | KColorScheme(QPalette::Active, KColorScheme::Window), | ||
612 | colorsStream << gtkColorsHelper("theme_titlebar_background_backdrop", "rgb(" + g.readEntry("inactiveBackground", "") + ")"); | 642 | KColorScheme(QPalette::Active, KColorScheme::Button), | ||
613 | colorsStream << gtkColorsHelper("theme_titlebar_foreground_insensitive", "rgb(" + g.readEntry("inactiveForeground", "") + ")"); | 643 | KColorScheme(QPalette::Active, KColorScheme::Selection), | ||
614 | colorsStream << gtkColorsHelper("theme_titlebar_foreground_insensitive_backdrop", "rgb(" + g.readEntry("inactiveForeground", "") + ")"); | 644 | KColorScheme(QPalette::Active, KColorScheme::Tooltip), | ||
645 | KColorScheme(QPalette::Active, KColorScheme::Complementary) | ||||
646 | }; | ||||
647 | QList<KColorScheme> inactiveColorSchemes{ | ||||
648 | KColorScheme(QPalette::Inactive, KColorScheme::View), | ||||
649 | KColorScheme(QPalette::Inactive, KColorScheme::Window), | ||||
650 | KColorScheme(QPalette::Inactive, KColorScheme::Button), | ||||
651 | KColorScheme(QPalette::Inactive, KColorScheme::Selection), | ||||
652 | KColorScheme(QPalette::Inactive, KColorScheme::Tooltip), | ||||
653 | KColorScheme(QPalette::Inactive, KColorScheme::Complementary) | ||||
654 | }; | ||||
655 | QList<KColorScheme> disabledColorSchemes{ | ||||
656 | KColorScheme(QPalette::Disabled, KColorScheme::View), | ||||
657 | KColorScheme(QPalette::Disabled, KColorScheme::Window), | ||||
658 | KColorScheme(QPalette::Disabled, KColorScheme::Button), | ||||
659 | KColorScheme(QPalette::Disabled, KColorScheme::Selection), | ||||
660 | KColorScheme(QPalette::Disabled, KColorScheme::Tooltip), | ||||
661 | KColorScheme(QPalette::Disabled, KColorScheme::Complementary) | ||||
662 | }; | ||||
663 | | ||||
664 | exportGtkColors(activeColorSchemes, inactiveColorSchemes, disabledColorSchemes, groupWMTheme, colorsStream); | ||||
615 | } | 665 | } | ||
616 | } | 666 | } | ||
617 | 667 | | |||
618 | // ----------------------------------------------------------------------------- | 668 | // ----------------------------------------------------------------------------- | ||
619 | 669 | | |||
620 | void runRdb( uint flags ) | 670 | void runRdb( uint flags ) | ||
621 | { | 671 | { | ||
622 | // Obtain the application palette that is about to be set. | 672 | // Obtain the application palette that is about to be set. | ||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Line(s) | 879 | #endif | |||
929 | kde4generalGroup.writeEntry("widgetStyle", kglobals.readEntry("widgetStyle", "breeze")); | 979 | kde4generalGroup.writeEntry("widgetStyle", kglobals.readEntry("widgetStyle", "breeze")); | ||
930 | 980 | | |||
931 | //toolbar style | 981 | //toolbar style | ||
932 | KConfigGroup toolbars4(&kde4config, "Toolbar style"); | 982 | KConfigGroup toolbars4(&kde4config, "Toolbar style"); | ||
933 | KConfigGroup toolbars5(kglobalcfg, "Toolbar style"); | 983 | KConfigGroup toolbars5(kglobalcfg, "Toolbar style"); | ||
934 | toolbars4.writeEntry("ToolButtonStyle", toolbars5.readEntry("ToolButtonStyle", "TextBesideIcon")); | 984 | toolbars4.writeEntry("ToolButtonStyle", toolbars5.readEntry("ToolButtonStyle", "TextBesideIcon")); | ||
935 | toolbars4.writeEntry("ToolButtonStyleOtherToolbars", toolbars5.readEntry("ToolButtonStyleOtherToolbars", "TextBesideIcon")); | 985 | toolbars4.writeEntry("ToolButtonStyleOtherToolbars", toolbars5.readEntry("ToolButtonStyleOtherToolbars", "TextBesideIcon")); | ||
936 | 986 | | |||
987 | if (exportGtkColors) { | ||||
937 | saveGtkColors(); | 988 | saveGtkColors(); | ||
938 | } | 989 | } | ||
990 | } | ||||
939 | No newline at end of file | 991 | No newline at end of file |