prune ColorRole enum

all the former combinations are now obtained with
ColorRole + ColorGroup
This commit is contained in:
Marco Martin 2014-06-19 18:18:50 +02:00
parent 8eb1bc10f5
commit 17741fbfae
3 changed files with 126 additions and 140 deletions

View File

@ -398,26 +398,28 @@ const QString ThemePrivate::processStyleSheet(const QString &css)
QHash<QString, QString> elements;
// If you add elements here, make sure their names are sufficiently unique to not cause
// clashes between element keys
elements[QStringLiteral("%textcolor")] = color(Theme::TextColor).name();
elements[QStringLiteral("%backgroundcolor")] = color(Theme::BackgroundColor).name();
elements[QStringLiteral("%highlightcolor")] = color(Theme::HighlightColor).name();
elements[QStringLiteral("%visitedlink")] = color(Theme::VisitedLinkColor).name();
elements[QStringLiteral("%activatedlink")] = color(Theme::HighlightColor).name();
elements[QStringLiteral("%hoveredlink")] = color(Theme::HighlightColor).name();
elements[QStringLiteral("%link")] = color(Theme::LinkColor).name();
elements[QStringLiteral("%buttontextcolor")] = color(Theme::ButtonTextColor).name();
elements[QStringLiteral("%buttonbackgroundcolor")] = color(Theme::ButtonBackgroundColor).name();
elements[QStringLiteral("%buttonhovercolor")] = color(Theme::ButtonHoverColor).name();
elements[QStringLiteral("%buttonfocuscolor")] = color(Theme::ButtonFocusColor).name();
elements[QStringLiteral("%viewtextcolor")] = color(Theme::ViewTextColor).name();
elements[QStringLiteral("%viewbackgroundcolor")] = color(Theme::ViewBackgroundColor).name();
elements[QStringLiteral("%viewhovercolor")] = color(Theme::ViewHoverColor).name();
elements[QStringLiteral("%viewfocuscolor")] = color(Theme::ViewFocusColor).name();
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("%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();
elements[QStringLiteral("%link")] = color(Theme::LinkColor, Theme::NormalColorGroup).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();
elements[QStringLiteral("%buttontextcolor")] = color(Theme::TextColor, Theme::ButtonColorGroup).name();
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("%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("%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();
QFont font = QGuiApplication::font();
elements[QStringLiteral("%fontsize")] = QStringLiteral("%1pt").arg(font.pointSize());
@ -528,107 +530,104 @@ void ThemePrivate::saveSvgElementsCache()
QColor ThemePrivate::color(Theme::ColorRole role, Theme::ColorGroup group) const
{
const KColorScheme *scheme = 0;
switch (group) {
case Theme::ButtonColorGroup: {
scheme = &buttonColorScheme;
break;
}
case Theme::ViewColorGroup: {
scheme = &viewColorScheme;
break;
}
//this doesn't have a real kcolorscheme
case Theme::ComplementaryColorGroup: {
switch (role) {
case Theme::TextColor: {
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::BackgroundColor: {
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::HighlightColor:
case Theme::HoverColor: {
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::FocusColor: {
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: {
KConfigGroup cg(colors, "Colors:Complementary");
if (cg.isValid()) {
return cg.readEntry("ForegroundLink", viewColorScheme.foreground(KColorScheme::LinkText).color());
} else {
return viewColorScheme.foreground(KColorScheme::LinkText).color();
}
}
case Theme::VisitedLinkColor: {
KConfigGroup cg(colors, "Colors:Complementary");
if (cg.isValid()) {
return cg.readEntry("ForegroundVisited", viewColorScheme.foreground(KColorScheme::VisitedText).color());
} else {
return viewColorScheme.foreground(KColorScheme::VisitedText).color();
}
}
}
break;
}
case Theme::NormalColorGroup:
default: {
scheme = &colorScheme;
break;
}
}
switch (role) {
case Theme::TextColor: {
switch (group) {
case Theme::ButtonColorGroup:
return buttonColorScheme.foreground(KColorScheme::NormalText).color();
case Theme::ViewColorGroup:
return viewColorScheme.foreground(KColorScheme::NormalText).color();
case Theme::ComplementaryColorGroup:
return color(Theme::ComplementaryTextColor, group);
default:
return colorScheme.foreground(KColorScheme::NormalText).color();
}
}
case Theme::HighlightColor: {
switch (group) {
case Theme::ButtonColorGroup:
return buttonColorScheme.decoration(KColorScheme::HoverColor).color();
case Theme::ViewColorGroup:
return viewColorScheme.decoration(KColorScheme::HoverColor).color();
case Theme::ComplementaryColorGroup:
return color(Theme::ComplementaryHoverColor, group);
default:
return colorScheme.decoration(KColorScheme::HoverColor).color();
}
}
case Theme::TextColor:
return scheme->foreground(KColorScheme::NormalText).color();
case Theme::BackgroundColor: {
switch (group) {
case Theme::ButtonColorGroup:
return buttonColorScheme.background(KColorScheme::NormalBackground).color();
case Theme::ViewColorGroup:
return viewColorScheme.background(KColorScheme::NormalBackground).color();
case Theme::ComplementaryColorGroup:
return color(Theme::ComplementaryBackgroundColor, group);
default:
return colorScheme.background(KColorScheme::NormalBackground).color();
}
}
case Theme::BackgroundColor:
return scheme->background(KColorScheme::NormalBackground).color();
case Theme::ButtonTextColor:
return buttonColorScheme.foreground(KColorScheme::NormalText).color();
case Theme::HighlightColor:
case Theme::HoverColor:
return scheme->decoration(KColorScheme::HoverColor).color();
case Theme::ButtonBackgroundColor:
return buttonColorScheme.background(KColorScheme::NormalBackground).color();
case Theme::FocusColor:
return scheme->decoration(KColorScheme::FocusColor).color();
case Theme::ButtonHoverColor:
return buttonColorScheme.decoration(KColorScheme::HoverColor).color();
case Theme::ButtonFocusColor:
return buttonColorScheme.decoration(KColorScheme::FocusColor).color();
case Theme::ViewTextColor:
return viewColorScheme.foreground(KColorScheme::NormalText).color();
case Theme::ViewBackgroundColor:
return viewColorScheme.background(KColorScheme::NormalBackground).color();
case Theme::ViewHoverColor:
return viewColorScheme.decoration(KColorScheme::HoverColor).color();
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();
return scheme->foreground(KColorScheme::LinkText).color();
case Theme::VisitedLinkColor:
return viewColorScheme.foreground(KColorScheme::VisitedText).color();
return scheme->foreground(KColorScheme::VisitedText).color();
}
return QColor();

View File

@ -484,12 +484,12 @@ QColor Theme::backgroundColor() const
QColor Theme::buttonTextColor() const
{
return Plasma::Theme::color(Plasma::Theme::ButtonTextColor);
return Plasma::Theme::color(Plasma::Theme::TextColor, Plasma::Theme::ButtonColorGroup);
}
QColor Theme::buttonBackgroundColor() const
{
return Plasma::Theme::color(Plasma::Theme::ButtonBackgroundColor);
return Plasma::Theme::color(Plasma::Theme::BackgroundColor, Plasma::Theme::ButtonColorGroup);
}
QColor Theme::linkColor() const
@ -504,52 +504,52 @@ QColor Theme::visitedLinkColor() const
QColor Theme::buttonHoverColor() const
{
return Plasma::Theme::color(Plasma::Theme::ButtonHoverColor);
return Plasma::Theme::color(Plasma::Theme::HoverColor, Plasma::Theme::ButtonColorGroup);
}
QColor Theme::buttonFocusColor() const
{
return Plasma::Theme::color(Plasma::Theme::ButtonFocusColor);
return Plasma::Theme::color(Plasma::Theme::FocusColor, Plasma::Theme::ButtonColorGroup);
}
QColor Theme::viewTextColor() const
{
return Plasma::Theme::color(Plasma::Theme::ViewTextColor);
return Plasma::Theme::color(Plasma::Theme::TextColor, Plasma::Theme::ViewColorGroup);
}
QColor Theme::viewBackgroundColor() const
{
return Plasma::Theme::color(Plasma::Theme::ViewBackgroundColor);
return Plasma::Theme::color(Plasma::Theme::BackgroundColor, Plasma::Theme::ViewColorGroup);
}
QColor Theme::viewHoverColor() const
{
return Plasma::Theme::color(Plasma::Theme::ViewHoverColor);
return Plasma::Theme::color(Plasma::Theme::HoverColor, Plasma::Theme::ViewColorGroup);
}
QColor Theme::viewFocusColor() const
{
return Plasma::Theme::color(Plasma::Theme::ViewFocusColor);
return Plasma::Theme::color(Plasma::Theme::FocusColor, Plasma::Theme::ViewColorGroup);
}
QColor Theme::complementaryTextColor() const
{
return Plasma::Theme::color(Plasma::Theme::ComplementaryTextColor);
return Plasma::Theme::color(Plasma::Theme::TextColor, Plasma::Theme::ComplementaryColorGroup);
}
QColor Theme::complementaryBackgroundColor() const
{
return Plasma::Theme::color(Plasma::Theme::ComplementaryBackgroundColor);
return Plasma::Theme::color(Plasma::Theme::BackgroundColor, Plasma::Theme::ComplementaryColorGroup);
}
QColor Theme::complementaryHoverColor() const
{
return Plasma::Theme::color(Plasma::Theme::ComplementaryHoverColor);
return Plasma::Theme::color(Plasma::Theme::HoverColor, Plasma::Theme::ComplementaryColorGroup);
}
QColor Theme::complementaryFocusColor() const
{
return Plasma::Theme::color(Plasma::Theme::ComplementaryFocusColor);
return Plasma::Theme::color(Plasma::Theme::FocusColor, Plasma::Theme::ComplementaryColorGroup);
}
QSizeF Theme::mSize(const QFont &font) const

View File

@ -92,23 +92,10 @@ public:
BackgroundColor = 1, /**< the default background color */
HighlightColor = 2, /**< the text highlight color to be used by items resting
on the background */
LinkColor = 3, /** color for clickable links */
VisitedLinkColor = 4, /** color visited clickable links */
ButtonTextColor = 100, /** text color for buttons */
ButtonBackgroundColor = 101, /** background color for buttons*/
ButtonHoverColor = 102, /** color for hover effect on buttons */
ButtonFocusColor = 103, /** color for focus effect on buttons */
ViewTextColor = 200, /** text color for views */
ViewBackgroundColor = 201, /** background color for views */
ViewHoverColor = 202, /** color for hover effect on view */
ViewFocusColor = 203, /** color for focus effect on view */
ComplementaryTextColor = 300, /** text color for "complementary" areas */
ComplementaryBackgroundColor = 301, /** background color for "complementary" areas */
ComplementaryHoverColor = 302, /** text color for "complementary" areas */
ComplementaryFocusColor = 303 /** background color for "complementary" areas */
HoverColor = 3, /** color for hover effect on view */
FocusColor = 4, /** color for focus effect on view */
LinkColor = 5, /** color for clickable links */
VisitedLinkColor = 6, /** color visited clickable links */
};
enum ColorGroup {