From 553a9bfe53a48d0d042eb8fe18342137ddbfdca1 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 13 Apr 2016 10:43:27 +0200 Subject: [PATCH] bind highlightedText color in Plasma::Theme we have a color in the Plasma theme "highlight" that is basically an accent color used around.. but one of the uses is to use it as a background, such as highlighted text. in that case we don't know what color would be safe for contrasting on top of it for things like the highlighted text color (plasma style used the background color for that, which is incorrect) REVIEW:127637 --- .../data/plasma/desktoptheme/testtheme/colors | 120 ++++++++++++++++++ .../desktoptheme/testtheme/metadata.desktop | 20 +++ autotests/themetest.cpp | 73 +++++++++++ autotests/themetest.h | 2 + src/declarativeimports/core/colorscope.cpp | 11 ++ src/declarativeimports/core/colorscope.h | 8 +- src/declarativeimports/core/quicktheme.cpp | 20 +++ src/declarativeimports/core/quicktheme.h | 34 ++++- .../plasmastyle/TextAreaStyle.qml | 2 +- .../plasmastyle/TextFieldStyle.qml | 2 +- src/plasma/private/theme_p.cpp | 15 ++- src/plasma/theme.h | 1 + 12 files changed, 302 insertions(+), 6 deletions(-) create mode 100644 autotests/data/plasma/desktoptheme/testtheme/colors create mode 100644 autotests/data/plasma/desktoptheme/testtheme/metadata.desktop diff --git a/autotests/data/plasma/desktoptheme/testtheme/colors b/autotests/data/plasma/desktoptheme/testtheme/colors new file mode 100644 index 000000000..e242dbb0e --- /dev/null +++ b/autotests/data/plasma/desktoptheme/testtheme/colors @@ -0,0 +1,120 @@ +[ColorEffects:Disabled] +Color=56,56,56 +ColorAmount=0 +ColorEffect=0 +ContrastAmount=0.65 +ContrastEffect=1 +IntensityAmount=0.1 +IntensityEffect=2 + +[ColorEffects:Inactive] +ChangeSelectionColor=true +Color=112,111,110 +ColorAmount=0.025 +ColorEffect=2 +ContrastAmount=0.1 +ContrastEffect=2 +Enable=false +IntensityAmount=0 +IntensityEffect=0 + +[Colors:Button] +BackgroundAlternate=224,223,222 +BackgroundNormal=239,240,241 +DecorationFocus=30,146,255 +DecorationHover=61,174,230 +ForegroundActive=246,116,0 +ForegroundInactive=175,176,179 +ForegroundLink=61,174,230 +ForegroundNegative=237,21,21 +ForegroundNeutral=201,206,59 +ForegroundNormal=49,54,59 +ForegroundPositive=17,209,22 +ForegroundVisited=61,174,230 + +[Colors:Selection] +BackgroundAlternate=48,138,183 +BackgroundNormal=61,174,230 +DecorationFocus=30,146,255 +DecorationHover=61,174,230 +ForegroundActive=246,116,0 +ForegroundInactive=146,204,230 +ForegroundLink=252,252,252 +ForegroundNegative=237,21,21 +ForegroundNeutral=201,206,59 +ForegroundNormal=252,252,252 +ForegroundPositive=17,209,22 +ForegroundVisited=252,252,252 + +[Colors:Tooltip] +BackgroundAlternate=196,224,255 +BackgroundNormal=239,240,241 +DecorationFocus=30,146,255 +DecorationHover=61,174,230 +ForegroundActive=246,116,0 +ForegroundInactive=175,176,179 +ForegroundLink=61,174,230 +ForegroundNegative=237,21,21 +ForegroundNeutral=201,206,59 +ForegroundNormal=49,54,59 +ForegroundPositive=17,209,22 +ForegroundVisited=61,174,230 + +[Colors:View] +BackgroundAlternate=248,247,246 +BackgroundNormal=252,252,252 +DecorationFocus=30,146,255 +DecorationHover=61,174,230 +ForegroundActive=246,116,0 +ForegroundInactive=175,176,179 +ForegroundLink=61,174,230 +ForegroundNegative=237,21,21 +ForegroundNeutral=201,206,59 +ForegroundNormal=49,54,59 +ForegroundPositive=17,209,22 +ForegroundVisited=61,174,230 + +[Colors:Window] +BackgroundAlternate=218,217,216 +BackgroundNormal=239,240,241 +DecorationFocus=30,146,255 +DecorationHover=61,174,230 +ForegroundActive=246,116,0 +ForegroundInactive=175,176,179 +ForegroundLink=61,174,230 +ForegroundNegative=237,21,21 +ForegroundNeutral=201,206,59 +ForegroundNormal=49,54,59 +ForegroundPositive=17,209,22 +ForegroundVisited=61,174,230 + +[Colors:Complementary] +BackgroundAlternate=59,64,69 +BackgroundNormal=49,54,59 +DecorationFocus=40,146,255 +DecorationHover=71,174,230 +ForegroundActive=246,116,20 +ForegroundInactive=185,176,179 +ForegroundLink=71,174,230 +ForegroundNegative=247,21,21 +ForegroundNeutral=201,206,69 +ForegroundNormal=239,240,241 +ForegroundPositive=27,209,22 +ForegroundVisited=71,174,230 + + +[General] +ColorScheme=Breeze +Name=Breeze +shadeSortColumn=true + +[KDE] +contrast=7 + +[WM] +activeBackground=61,174,230 +activeBlend=252,252,252 +activeForeground=252,252,252 +inactiveBackground=123,124,126 +inactiveBlend=123,124,126 +inactiveForeground=252,252,252 diff --git a/autotests/data/plasma/desktoptheme/testtheme/metadata.desktop b/autotests/data/plasma/desktoptheme/testtheme/metadata.desktop new file mode 100644 index 000000000..18936e6eb --- /dev/null +++ b/autotests/data/plasma/desktoptheme/testtheme/metadata.desktop @@ -0,0 +1,20 @@ +[Desktop Entry] +Name=Plasma test theme + + +X-KDE-PluginInfo-Author=KDE Visual Design Group +X-KDE-PluginInfo-Email=kde-artists@kde.org +X-KDE-PluginInfo-Name=default +X-KDE-PluginInfo-Version=5.20 +X-KDE-PluginInfo-Website=http://plasma.kde.org +X-KDE-PluginInfo-Category= +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-EnabledByDefault=true +X-Plasma-API=5.0 + +[ContrastEffect] +enabled=true +contrast=0.2 +intensity=2.0 +saturation=1.7 diff --git a/autotests/themetest.cpp b/autotests/themetest.cpp index 2165bef9a..399224600 100644 --- a/autotests/themetest.cpp +++ b/autotests/themetest.cpp @@ -36,6 +36,7 @@ void ThemeTest::initTestCase() // set default icon theme to test-theme QStandardPaths::setTestModeEnabled(true); + m_theme = new Plasma::Theme("testtheme", this); QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); if(!QDir(configPath).mkpath(QStringLiteral("."))) { @@ -95,5 +96,77 @@ void ThemeTest::loadSvgIcon() QVERIFY(!m_svg->theme()->findInCache(cacheId, result)); } +void ThemeTest::testColors() +{ + QCOMPARE(m_theme->color(Plasma::Theme::TextColor, + Plasma::Theme::NormalColorGroup), QColor(49,54,59)); + QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, + Plasma::Theme::NormalColorGroup), QColor(239,240,241)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, + Plasma::Theme::NormalColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, + Plasma::Theme::NormalColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, + Plasma::Theme::NormalColorGroup), QColor(30,146,255)); + QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, + Plasma::Theme::NormalColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, + Plasma::Theme::NormalColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, + Plasma::Theme::NormalColorGroup).name(), QColor(163,214,251).name()); + + QCOMPARE(m_theme->color(Plasma::Theme::TextColor, + Plasma::Theme::ButtonColorGroup), QColor(49,54,59)); + QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, + Plasma::Theme::ButtonColorGroup), QColor(239,240,241)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, + Plasma::Theme::ButtonColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, + Plasma::Theme::ButtonColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, + Plasma::Theme::ButtonColorGroup), QColor(30,146,255)); + QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, + Plasma::Theme::ButtonColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, + Plasma::Theme::ButtonColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, + Plasma::Theme::ButtonColorGroup).name(), QColor(163,214,251).name()); + + QCOMPARE(m_theme->color(Plasma::Theme::TextColor, + Plasma::Theme::ViewColorGroup), QColor(49,54,59)); + QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, + Plasma::Theme::ViewColorGroup), QColor(252,252,252)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, + Plasma::Theme::ViewColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, + Plasma::Theme::ViewColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, + Plasma::Theme::ViewColorGroup), QColor(30,146,255)); + QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, + Plasma::Theme::ViewColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, + Plasma::Theme::ViewColorGroup), QColor(61,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, + Plasma::Theme::ViewColorGroup).name(), QColor(163,214,251).name()); + + QCOMPARE(m_theme->color(Plasma::Theme::TextColor, + Plasma::Theme::ComplementaryColorGroup), QColor(239,240,241)); + QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, + Plasma::Theme::ComplementaryColorGroup), QColor(49,54,59)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, + Plasma::Theme::ComplementaryColorGroup), QColor(71,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, + Plasma::Theme::ComplementaryColorGroup), QColor(71,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, + Plasma::Theme::ComplementaryColorGroup), QColor(40,146,255)); + QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, + Plasma::Theme::ComplementaryColorGroup), QColor(71,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, + Plasma::Theme::ComplementaryColorGroup), QColor(71,174,230)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, + Plasma::Theme::ComplementaryColorGroup).name(), QColor(169,214,249).name()); +} + + QTEST_MAIN(ThemeTest) diff --git a/autotests/themetest.h b/autotests/themetest.h index b6042c027..799533fdb 100644 --- a/autotests/themetest.h +++ b/autotests/themetest.h @@ -34,9 +34,11 @@ public Q_SLOTS: private Q_SLOTS: void loadSvgIcon(); + void testColors(); private: Plasma::Svg *m_svg; + Plasma::Theme *m_theme; }; #endif diff --git a/src/declarativeimports/core/colorscope.cpp b/src/declarativeimports/core/colorscope.cpp index 98ff3abe7..5f7363bb5 100644 --- a/src/declarativeimports/core/colorscope.cpp +++ b/src/declarativeimports/core/colorscope.cpp @@ -154,6 +154,17 @@ QColor ColorScope::highlightColor() const return m_theme.color(Plasma::Theme::HighlightColor, m_group); } +QColor ColorScope::highlightedTextColor() const +{ + if (m_inherit) { + ColorScope *s = findParentScope(); + if (s) { + return s->highlightedTextColor(); + } + } + return m_theme.color(Plasma::Theme::HighlightedTextColor, m_group); +} + QColor ColorScope::backgroundColor() const { if (m_inherit) { diff --git a/src/declarativeimports/core/colorscope.h b/src/declarativeimports/core/colorscope.h index 38e7cc8f8..b0f0ada79 100644 --- a/src/declarativeimports/core/colorscope.h +++ b/src/declarativeimports/core/colorscope.h @@ -54,6 +54,11 @@ class ColorScope : public QQuickItem */ Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY colorsChanged) + /** + * The highlighted text color within this colorscope + */ + Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor NOTIFY colorsChanged) + /** * The background color that should be used within this colorscope */ @@ -69,8 +74,9 @@ public: QColor textColor() const; QColor highlightColor() const; + QColor highlightedTextColor() const; QColor backgroundColor() const; - + ////NEEDED BY QML TO CREATE ATTACHED PROPERTIES static ColorScope *qmlAttachedProperties(QObject *object); diff --git a/src/declarativeimports/core/quicktheme.cpp b/src/declarativeimports/core/quicktheme.cpp index 3ef5b8821..3411b3d02 100644 --- a/src/declarativeimports/core/quicktheme.cpp +++ b/src/declarativeimports/core/quicktheme.cpp @@ -44,6 +44,11 @@ QColor QuickTheme::highlightColor() const return Plasma::Theme::color(Plasma::Theme::HighlightColor); } +QColor QuickTheme::highlightedTextColor() const +{ + return Plasma::Theme::color(Plasma::Theme::HighlightedTextColor); +} + QColor QuickTheme::backgroundColor() const { return Plasma::Theme::color(Plasma::Theme::BackgroundColor); @@ -79,6 +84,11 @@ QColor QuickTheme::buttonFocusColor() const return Plasma::Theme::color(Plasma::Theme::FocusColor, Plasma::Theme::ButtonColorGroup); } +QColor QuickTheme::buttonHighlightedTextColor() const +{ + return Plasma::Theme::color(Plasma::Theme::HighlightedTextColor, Plasma::Theme::ButtonColorGroup); +} + QColor QuickTheme::viewTextColor() const { return Plasma::Theme::color(Plasma::Theme::TextColor, Plasma::Theme::ViewColorGroup); @@ -99,6 +109,11 @@ QColor QuickTheme::viewFocusColor() const return Plasma::Theme::color(Plasma::Theme::FocusColor, Plasma::Theme::ViewColorGroup); } +QColor QuickTheme::viewHighlightedTextColor() const +{ + return Plasma::Theme::color(Plasma::Theme::HighlightedTextColor, Plasma::Theme::ViewColorGroup); +} + QColor QuickTheme::complementaryTextColor() const { return Plasma::Theme::color(Plasma::Theme::TextColor, Plasma::Theme::ComplementaryColorGroup); @@ -119,6 +134,11 @@ QColor QuickTheme::complementaryFocusColor() const return Plasma::Theme::color(Plasma::Theme::FocusColor, Plasma::Theme::ComplementaryColorGroup); } +QColor QuickTheme::complementaryHighlightedTextColor() const +{ + return Plasma::Theme::color(Plasma::Theme::HighlightedTextColor, Plasma::Theme::ComplementaryColorGroup); +} + } #include "moc_quicktheme.cpp" diff --git a/src/declarativeimports/core/quicktheme.h b/src/declarativeimports/core/quicktheme.h index 79db53c76..f1af4ca2b 100644 --- a/src/declarativeimports/core/quicktheme.h +++ b/src/declarativeimports/core/quicktheme.h @@ -49,22 +49,28 @@ class QuickTheme : public Plasma::Theme // colors Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY themeChangedProxy) + Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY themeChangedProxy) - Q_PROPERTY(QColor buttonTextColor READ buttonTextColor NOTIFY themeChangedProxy) - Q_PROPERTY(QColor buttonBackgroundColor READ buttonBackgroundColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor linkColor READ linkColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor visitedLinkColor READ visitedLinkColor NOTIFY themeChangedProxy) + + Q_PROPERTY(QColor buttonTextColor READ buttonTextColor NOTIFY themeChangedProxy) + Q_PROPERTY(QColor buttonBackgroundColor READ buttonBackgroundColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor buttonHoverColor READ buttonHoverColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor buttonFocusColor READ buttonFocusColor NOTIFY themeChangedProxy) + Q_PROPERTY(QColor buttonHighlightedTextColor READ buttonHighlightedTextColor NOTIFY themeChangedProxy) + Q_PROPERTY(QColor viewTextColor READ viewTextColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY themeChangedProxy) + Q_PROPERTY(QColor viewHighlightedTextColor READ viewHighlightedTextColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor complementaryTextColor READ complementaryTextColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor complementaryBackgroundColor READ complementaryBackgroundColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor complementaryHoverColor READ viewHoverColor NOTIFY themeChangedProxy) Q_PROPERTY(QColor complementaryFocusColor READ viewFocusColor NOTIFY themeChangedProxy) + Q_PROPERTY(QColor complementaryHighlightedTextColor READ complementaryHighlightedTextColor NOTIFY themeChangedProxy) public: explicit QuickTheme(QObject *parent = 0); @@ -84,6 +90,12 @@ public: */ QColor highlightColor() const; + /** + * @return The theme's colorscheme's highlighted text color + * @since 5.22 + */ + QColor highlightedTextColor() const; + /** * @return The theme's colorscheme's background color * @since 5.0 @@ -126,6 +138,12 @@ public: */ QColor buttonFocusColor() const; + /** + * @return The theme's colorscheme's highlighted text color for buttons + * @since 5.22 + */ + QColor buttonHighlightedTextColor() const; + /** * @return The theme's colorscheme's text color in views * @since 5.0 @@ -150,6 +168,12 @@ public: */ QColor viewFocusColor() const; + /** + * @return The theme's colorscheme's highlighted text color for views + * @since 5.22 + */ + QColor viewHighlightedTextColor() const; + /** * @return The theme's colorscheme's text color of "complementary" areas * @since 5.0 @@ -174,6 +198,12 @@ public: */ QColor complementaryFocusColor() const; + /** + * @return The theme's colorscheme's highlighted text color for "complementary" areas + * @since 5.22 + */ + QColor complementaryHighlightedTextColor() const; + Q_SIGNALS: void themeChangedProxy(); }; diff --git a/src/declarativeimports/plasmastyle/TextAreaStyle.qml b/src/declarativeimports/plasmastyle/TextAreaStyle.qml index f5be27ca0..394326e73 100644 --- a/src/declarativeimports/plasmastyle/TextAreaStyle.qml +++ b/src/declarativeimports/plasmastyle/TextAreaStyle.qml @@ -39,7 +39,7 @@ QtQuickControlStyle.TextAreaStyle { backgroundColor: "transparent" textColor: control.backgroundVisible ? theme.viewTextColor : PlasmaCore.ColorScope.textColor selectionColor: control.backgroundVisible ? theme.viewFocusColor : PlasmaCore.ColorScope.highlightColor - selectedTextColor: control.backgroundVisible ? theme.viewBackgroundColor : PlasmaCore.ColorScope.backgroundColor + selectedTextColor: control.backgroundVisible ? theme.viewHighlightedTextColor : PlasmaCore.ColorScope.highlightedTextColor renderType: Text.NativeRendering diff --git a/src/declarativeimports/plasmastyle/TextFieldStyle.qml b/src/declarativeimports/plasmastyle/TextFieldStyle.qml index 447d7e36a..05ff3d542 100644 --- a/src/declarativeimports/plasmastyle/TextFieldStyle.qml +++ b/src/declarativeimports/plasmastyle/TextFieldStyle.qml @@ -31,7 +31,7 @@ QtQuickControlStyle.TextFieldStyle { textColor: control.enabled ? theme.viewTextColor : Qt.rgba(theme.viewTextColor.r, theme.viewTextColor.g, theme.viewTextColor.b, 0.6) selectionColor: theme.viewFocusColor - selectedTextColor: theme.viewBackgroundColor + selectedTextColor: theme.viewHighlightedTextColor placeholderTextColor: Qt.rgba(theme.viewTextColor.r, theme.viewTextColor.g, theme.viewTextColor.b, 0.5) /* diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index 603cf0ab8..1aaf021a9 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -439,6 +439,7 @@ const QString ThemePrivate::processStyleSheet(const QString &css) elements[QStringLiteral("%textcolor")] = color(Theme::TextColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%backgroundcolor")] = color(Theme::BackgroundColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%highlightcolor")] = color(Theme::HighlightColor, Theme::NormalColorGroup).name(); + elements[QStringLiteral("%highlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%visitedlink")] = color(Theme::VisitedLinkColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%activatedlink")] = color(Theme::HighlightColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%hoveredlink")] = color(Theme::HighlightColor, Theme::NormalColorGroup).name(); @@ -448,16 +449,19 @@ const QString ThemePrivate::processStyleSheet(const QString &css) elements[QStringLiteral("%buttonbackgroundcolor")] = color(Theme::BackgroundColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonhovercolor")] = color(Theme::HoverColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonfocuscolor")] = color(Theme::FocusColor, Theme::ButtonColorGroup).name(); + elements[QStringLiteral("%buttonhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%viewtextcolor")] = color(Theme::TextColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewbackgroundcolor")] = color(Theme::BackgroundColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewhovercolor")] = color(Theme::HoverColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewfocuscolor")] = color(Theme::FocusColor, Theme::ViewColorGroup).name(); + elements[QStringLiteral("%viewhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%complementarytextcolor")] = color(Theme::TextColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementarybackgroundcolor")] = color(Theme::BackgroundColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementaryhovercolor")] = color(Theme::HoverColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementaryfocuscolor")] = color(Theme::FocusColor, Theme::ComplementaryColorGroup).name(); + elements[QStringLiteral("%complementaryhighlightedtextcolor")] = color(Theme::TextColor, Theme::ComplementaryColorGroup).name(); QFont font = QGuiApplication::font(); elements[QStringLiteral("%fontsize")] = QStringLiteral("%1pt").arg(font.pointSize()); @@ -484,41 +488,47 @@ const QString ThemePrivate::svgStyleSheet(Plasma::Theme::ColorGroup group) stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%buttonbackgroundcolor")); stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%buttonhovercolor")); + stylesheet += skel.arg(QStringLiteral("HighlightedText"), QStringLiteral("%buttonhighlightedtextcolor")); break; case Theme::ViewColorGroup: stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%viewtextcolor")); stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%viewbackgroundcolor")); stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%viewhovercolor")); + stylesheet += skel.arg(QStringLiteral("HighlightedText"), QStringLiteral("%viewhighlightedtextcolor")); break; case Theme::ComplementaryColorGroup: stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%complementarytextcolor")); stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%complementarybackgroundcolor")); stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%complementaryhovercolor")); + stylesheet += skel.arg(QStringLiteral("HighlightedText"), QStringLiteral("%complementaryhighlightedtextcolor")); break; default: stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%textcolor")); stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%backgroundcolor")); stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%highlightcolor")); + stylesheet += skel.arg(QStringLiteral("HighlightedText"), QStringLiteral("%highlightedtextcolor")); } - stylesheet += skel.arg(QStringLiteral("ButtonText"), QStringLiteral("%buttontextcolor")); stylesheet += skel.arg(QStringLiteral("ButtonBackground"), QStringLiteral("%buttonbackgroundcolor")); stylesheet += skel.arg(QStringLiteral("ButtonHover"), QStringLiteral("%buttonhovercolor")); stylesheet += skel.arg(QStringLiteral("ButtonFocus"), QStringLiteral("%buttonfocuscolor")); + stylesheet += skel.arg(QStringLiteral("ButtonHighlightedText"), QStringLiteral("%buttonhighlightedtextcolor")); stylesheet += skel.arg(QStringLiteral("ViewText"), QStringLiteral("%viewtextcolor")); stylesheet += skel.arg(QStringLiteral("ViewBackground"), QStringLiteral("%viewbackgroundcolor")); stylesheet += skel.arg(QStringLiteral("ViewHover"), QStringLiteral("%viewhovercolor")); stylesheet += skel.arg(QStringLiteral("ViewFocus"), QStringLiteral("%viewfocuscolor")); + stylesheet += skel.arg(QStringLiteral("ViewHighlightedText"), QStringLiteral("%viewhighlightedtextcolor")); stylesheet += skel.arg(QStringLiteral("ComplementaryText"), QStringLiteral("%complementarytextcolor")); stylesheet += skel.arg(QStringLiteral("ComplementaryBackground"), QStringLiteral("%complementarybackgroundcolor")); stylesheet += skel.arg(QStringLiteral("ComplementaryHover"), QStringLiteral("%complementaryhovercolor")); stylesheet += skel.arg(QStringLiteral("ComplementaryFocus"), QStringLiteral("%complementaryfocuscolor")); + stylesheet += skel.arg(QStringLiteral("ComplementaryHighlightedText"), QStringLiteral("%complementaryhighlightedtextcolor")); stylesheet = processStyleSheet(stylesheet); cachedSvgStyleSheets.insert(group, stylesheet); @@ -623,6 +633,9 @@ QColor ThemePrivate::color(Theme::ColorRole role, Theme::ColorGroup group) const case Theme::VisitedLinkColor: return scheme->foreground(KColorScheme::VisitedText).color(); + + case Theme::HighlightedTextColor: + return scheme->shade(scheme->decoration(KColorScheme::HoverColor).color(), KColorScheme::LightShade, 1); } return QColor(); diff --git a/src/plasma/theme.h b/src/plasma/theme.h index 3f497198f..271328c45 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -75,6 +75,7 @@ public: FocusColor = 4, /** color for focus effect on view */ LinkColor = 5, /** color for clickable links */ VisitedLinkColor = 6, /** color visited clickable links */ + HighlightedTextColor = 7/** color contrasting with HighlightColor, to be used for instance with */ }; enum ColorGroup {