diff --git a/src/declarativeimports/core/colorscope.h b/src/declarativeimports/core/colorscope.h --- a/src/declarativeimports/core/colorscope.h +++ b/src/declarativeimports/core/colorscope.h @@ -20,6 +20,7 @@ #ifndef COLORSCOPE_H #define COLORSCOPE_H +#include #include #include #include @@ -47,37 +48,37 @@ /** * The main foreground color within this colorscope */ - Q_PROPERTY(QColor textColor READ textColor NOTIFY colorsChanged) + Q_PROPERTY(QColor textColor READ textColor WRITE setCustomTextColor NOTIFY colorsChanged) /** * The highlight color within this colorscope */ - Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY colorsChanged) + Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setCustomHighlightColor NOTIFY colorsChanged) /** * The highlighted text color within this colorscope */ - Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setCustomHighlightedTextColor NOTIFY colorsChanged) /** * The background color that should be used within this colorscope */ - Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY colorsChanged) + Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setCustomBackgroundColor NOTIFY colorsChanged) /** * Color of foreground objects with a "positive message" connotation (usually green) */ - Q_PROPERTY(QColor positiveTextColor READ positiveTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor positiveTextColor READ positiveTextColor WRITE setCustomPositiveTextColor NOTIFY colorsChanged) /** * Color of foreground objects with a "neutral message" connotation (usually yellow) */ - Q_PROPERTY(QColor neutralTextColor READ neutralTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor neutralTextColor READ neutralTextColor WRITE setCustomNeutralTextColor NOTIFY colorsChanged) /** * Color of foreground objects with a "negative message" connotation (usually red) */ - Q_PROPERTY(QColor negativeTextColor READ negativeTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor negativeTextColor READ negativeTextColor WRITE setCustomNegativeTextColor NOTIFY colorsChanged) /** * true if the scope inherits from its parent scope @@ -94,12 +95,25 @@ Plasma::Theme::ColorGroup colorGroup() const; QColor textColor() const; + void setCustomTextColor(QColor color); + QColor highlightColor() const; + void setCustomHighlightColor(QColor color); + QColor highlightedTextColor() const; + void setCustomHighlightedTextColor(QColor color); + QColor backgroundColor() const; + void setCustomBackgroundColor(QColor color); + QColor positiveTextColor() const; + void setCustomPositiveTextColor(QColor color); + QColor neutralTextColor() const; + void setCustomNeutralTextColor(QColor color); + QColor negativeTextColor() const; + void setCustomNegativeTextColor(QColor color); bool inherit() const; void setInherit(bool inherit); @@ -124,6 +138,15 @@ void setParentScope(ColorScope * parentScope); bool m_inherit; + + QColor m_cTextColor; + QColor m_cHighlightColor; + QColor m_cHighlightedTextColor; + QColor m_cBackgroundColor; + QColor m_cPositiveTextColor; + QColor m_cNeutralTextColor; + QColor m_cNegativeTextColor; + Plasma::Theme m_theme; Plasma::Theme::ColorGroup m_group; QPointer m_parentScope; diff --git a/src/declarativeimports/core/colorscope.cpp b/src/declarativeimports/core/colorscope.cpp --- a/src/declarativeimports/core/colorscope.cpp +++ b/src/declarativeimports/core/colorscope.cpp @@ -138,39 +138,158 @@ QColor ColorScope::textColor() const { + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + return m_parentScope ? m_parentScope->textColor() : m_cTextColor; + } + return m_theme.color(Plasma::Theme::TextColor, colorGroup()); } +void ColorScope::setCustomTextColor(QColor color) +{ + if (m_cTextColor == color) { + return; + } + + m_cTextColor = color; + + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + emit colorsChanged(); + } +} + QColor ColorScope::highlightColor() const { + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + return m_parentScope ? m_parentScope->highlightColor() : m_cHighlightColor; + } + return m_theme.color(Plasma::Theme::HighlightColor, colorGroup()); } +void ColorScope::setCustomHighlightColor(QColor color) +{ + if (m_cHighlightColor == color) { + return; + } + + m_cHighlightColor = color; + + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + emit colorsChanged(); + } +} + QColor ColorScope::highlightedTextColor() const { + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + return m_parentScope ? m_parentScope->highlightedTextColor() : m_cHighlightedTextColor; + } + return m_theme.color(Plasma::Theme::HighlightedTextColor, colorGroup()); } +void ColorScope::setCustomHighlightedTextColor(QColor color) +{ + if (m_cHighlightedTextColor == color) { + return; + } + + m_cHighlightedTextColor = color; + + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + emit colorsChanged(); + } +} + QColor ColorScope::backgroundColor() const { + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + return m_parentScope ? m_parentScope->backgroundColor() : m_cBackgroundColor; + } + return m_theme.color(Plasma::Theme::BackgroundColor, colorGroup()); } +void ColorScope::setCustomBackgroundColor(QColor color) +{ + if (m_cBackgroundColor == color) { + return; + } + + m_cBackgroundColor = color; + + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + emit colorsChanged(); + } +} + QColor ColorScope::positiveTextColor() const { + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + return m_parentScope ? m_parentScope->positiveTextColor() : m_cPositiveTextColor; + } + return m_theme.color(Plasma::Theme::PositiveTextColor, colorGroup()); } +void ColorScope::setCustomPositiveTextColor(QColor color) +{ + if (m_cPositiveTextColor == color) { + return; + } + + m_cPositiveTextColor = color; + + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + emit colorsChanged(); + } +} + QColor ColorScope::neutralTextColor() const { + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + return m_parentScope ? m_parentScope->neutralTextColor() : m_cNeutralTextColor; + } + return m_theme.color(Plasma::Theme::NeutralTextColor, colorGroup()); } +void ColorScope::setCustomNeutralTextColor(QColor color) +{ + if (m_cNeutralTextColor == color) { + return; + } + + m_cNeutralTextColor = color; + + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + emit colorsChanged(); + } +} + QColor ColorScope::negativeTextColor() const { + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + return m_parentScope ? m_parentScope->negativeTextColor() : m_cNegativeTextColor; + } + return m_theme.color(Plasma::Theme::NegativeTextColor, colorGroup()); } +void ColorScope::setCustomNegativeTextColor(QColor color) +{ + if (m_cNegativeTextColor == color) { + return; + } + + m_cNegativeTextColor = color; + + if (colorGroup() == Plasma::Theme::UserSetColorGroup) { + emit colorsChanged(); + } +} + bool ColorScope::inherit() const { return m_inherit; diff --git a/src/plasma/theme.h b/src/plasma/theme.h --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -85,7 +85,8 @@ NormalColorGroup = 0, ButtonColorGroup = 1, ViewColorGroup = 2, - ComplementaryColorGroup = 3 + ComplementaryColorGroup = 3, + UserSetColorGroup = 9 }; Q_ENUM(ColorGroup)