new color group of "complementary" colors

for areas intended to have independent background and text color than
all the rest, like the Logout dialog

if Colors:Complementary is not present in the theme, it falls back to
normal colors
This commit is contained in:
Marco Martin 2014-06-18 19:00:32 +02:00
parent d7d71e8a66
commit 4ad2cc5196
5 changed files with 123 additions and 4 deletions

View File

@ -88,9 +88,24 @@ ForegroundNormal=49,54,59
ForegroundPositive=17,209,22
ForegroundVisited=61,174,230
[Colors:Complementary]
BackgroundAlternate=59,64,69
BackgroundNormal=49,54,59
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=239,240,241
ForegroundPositive=17,209,22
ForegroundVisited=61,174,230
[General]
ColorScheme=Plasma Next
Name=Plasma Next
ColorScheme=Breeze
Name=Breeze
shadeSortColumn=true
[KDE]

View File

@ -414,6 +414,11 @@ const QString ThemePrivate::processStyleSheet(const QString &css)
elements[QStringLiteral("%viewhovercolor")] = color(Theme::ViewHoverColor).name();
elements[QStringLiteral("%viewfocuscolor")] = color(Theme::ViewFocusColor).name();
elements[QStringLiteral("%complementarytextcolor")] = color(Theme::ComplementaryTextColor).name();
elements[QStringLiteral("%complementarybackgroundcolor")] = color(Theme::ComplementaryBackgroundColor).name();
elements[QStringLiteral("%complementaryhovercolor")] = color(Theme::ComplementaryHoverColor).name();
elements[QStringLiteral("%complementaryfocuscolor")] = color(Theme::ComplementaryFocusColor).name();
QFont font = QGuiApplication::font();
elements[QStringLiteral("%fontsize")] = QStringLiteral("%1pt").arg(font.pointSize());
elements[QStringLiteral("%fontfamily")] = font.family().split('[').first();
@ -446,6 +451,12 @@ const QString ThemePrivate::svgStyleSheet(Plasma::Svg::ColorGroup group)
stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%viewhovercolor"));
break;
case Svg::ComplementaryColorGroup:
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%complementarytextcolor"));
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%complementarybackgroundcolor"));
stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%complementaryhovercolor"));
break;
default:
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%textcolor"));
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%backgroundcolor"));
@ -464,6 +475,11 @@ const QString ThemePrivate::svgStyleSheet(Plasma::Svg::ColorGroup group)
stylesheet += skel.arg(QStringLiteral("ViewHover"), QStringLiteral("%viewhovercolor"));
stylesheet += skel.arg(QStringLiteral("ViewFocus"), QStringLiteral("%viewfocuscolor"));
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 = processStyleSheet(stylesheet);
cachedSvgStyleSheets.insert(group, stylesheet);
}
@ -546,6 +562,38 @@ QColor ThemePrivate::color(Theme::ColorRole role) const
case Theme::ViewFocusColor:
return viewColorScheme.decoration(KColorScheme::FocusColor).color();
case Theme::ComplementaryTextColor: {
KConfigGroup cg(colors, "Colors:Complementary");
if (cg.isValid()) {
return cg.readEntry("ForegroundNormal", colorScheme.foreground(KColorScheme::NormalText).color());
} else {
return colorScheme.foreground(KColorScheme::NormalText).color();
}
}
case Theme::ComplementaryBackgroundColor: {
KConfigGroup cg(colors, "Colors:Complementary");
if (cg.isValid()) {
return cg.readEntry("BackgroundNormal", colorScheme.background(KColorScheme::NormalBackground).color());
} else {
return colorScheme.background(KColorScheme::NormalBackground).color();
}
}
case Theme::ComplementaryHoverColor: {
KConfigGroup cg(colors, "Colors:Complementary");
if (cg.isValid()) {
return cg.readEntry("DecorationFocus", colorScheme.decoration(KColorScheme::HoverColor).color());
} else {
return colorScheme.decoration(KColorScheme::HoverColor).color();
}
}
case Theme::ComplementaryFocusColor: {
KConfigGroup cg(colors, "Colors:Complementary");
if (cg.isValid()) {
return cg.readEntry("DecorationHover", colorScheme.decoration(KColorScheme::FocusColor).color());
} else {
return colorScheme.decoration(KColorScheme::FocusColor).color();
}
}
case Theme::LinkColor:
return viewColorScheme.foreground(KColorScheme::LinkText).color();

View File

@ -67,7 +67,8 @@ public:
enum ColorGroup {
NormalColorGroup = 0,
ButtonColorGroup = 1,
ViewColorGroup = 2
ViewColorGroup = 2,
ComplementaryColorGroup = 3
};
Q_ENUMS(ColorGroup)

View File

@ -532,6 +532,26 @@ QColor Theme::viewFocusColor() const
return Plasma::Theme::color(Plasma::Theme::ViewFocusColor);
}
QColor Theme::complementaryTextColor() const
{
return Plasma::Theme::color(Plasma::Theme::ComplementaryTextColor);
}
QColor Theme::complementaryBackgroundColor() const
{
return Plasma::Theme::color(Plasma::Theme::ComplementaryBackgroundColor);
}
QColor Theme::complementaryHoverColor() const
{
return Plasma::Theme::color(Plasma::Theme::ComplementaryHoverColor);
}
QColor Theme::complementaryFocusColor() const
{
return Plasma::Theme::color(Plasma::Theme::ComplementaryFocusColor);
}
QSizeF Theme::mSize(const QFont &font) const
{
return QFontMetrics(font).boundingRect("M").size();

View File

@ -81,6 +81,11 @@ class PLASMA_EXPORT Theme : public QObject
Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY themeChanged)
Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY themeChanged)
Q_PROPERTY(QColor complementaryTextColor READ complementaryTextColor NOTIFY themeChanged)
Q_PROPERTY(QColor complementaryBackgroundColor READ complementaryBackgroundColor NOTIFY themeChanged)
Q_PROPERTY(QColor complementaryHoverColor READ viewHoverColor NOTIFY themeChanged)
Q_PROPERTY(QColor complementaryFocusColor READ viewFocusColor NOTIFY themeChanged)
public:
enum ColorRole {
TextColor = 0, /**< the text color to be used by items resting on the background */
@ -93,10 +98,16 @@ public:
VisitedLinkColor = 32, /** color visited clickable links */
ButtonHoverColor = 64, /** color for hover effect on buttons */
ButtonFocusColor = 128, /** color for focus effect on buttons */
ViewTextColor = 256, /** text color for views */
ViewBackgroundColor = 512, /** background color for views */
ViewHoverColor = 1024, /** color for hover effect on view */
ViewFocusColor = 2048 /** color for focus effect on view */
ViewFocusColor = 2048, /** color for focus effect on view */
ComplementaryTextColor = 4096, /** text color for "complementary" areas */
ComplementaryBackgroundColor = 8192, /** background color for "complementary" areas */
ComplementaryHoverColor = 16384, /** text color for "complementary" areas */
ComplementaryFocusColor = 32768 /** background color for "complementary" areas */
};
/**
@ -419,6 +430,30 @@ public:
*/
QColor viewFocusColor() const;
/**
* @return The theme's colorscheme's text color of "complementary" areas
* @since 5.0
*/
QColor complementaryTextColor() const;
/**
* @return The theme's colorscheme's background color of "complementary" areas
* @since 5.0
*/
QColor complementaryBackgroundColor() const;
/**
* @return The theme's colorscheme's color of hovered "complementary" areas
* @since 5.0
*/
QColor complementaryHoverColor() const;
/**
* @return The theme's colorscheme's color of focused "complementary" areas
* @since 5.0
*/
QColor complementaryFocusColor() const;
/** This method allows Plasma to enable and disable the background
* contrast effect for a given theme, improving readability. The
* value is read from the "enabled" key in the "ContrastEffect"