diff --git a/applet.cpp b/applet.cpp index ab8ad820a..34d8f5279 100644 --- a/applet.cpp +++ b/applet.cpp @@ -89,7 +89,7 @@ protected: Q_UNUSED(widget) painter->save(); painter->setRenderHint(QPainter::Antialiasing); - QColor wash = Plasma::Theme::defaultTheme()->backgroundColor(); + QColor wash = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor); wash.setAlphaF(.6); painter->fillPath(parentItem()->shape(), wash); painter->restore(); diff --git a/svg.cpp b/svg.cpp index fbabe0adc..c3ee3c2af 100644 --- a/svg.cpp +++ b/svg.cpp @@ -173,7 +173,7 @@ class Svg::Private // Apply current color scheme if the svg asks for it if (applyColors) { QImage itmp = p.toImage(); - KIconEffect::colorize(itmp, Theme::defaultTheme()->backgroundColor(), 1.0); + KIconEffect::colorize(itmp, Theme::defaultTheme()->color(Theme::BackgroundColor), 1.0); p = p.fromImage(itmp); } diff --git a/theme.cpp b/theme.cpp index 82e7f11e9..6d9d32469 100644 --- a/theme.cpp +++ b/theme.cpp @@ -260,26 +260,30 @@ KSharedConfigPtr Theme::colorScheme() const return d->colors; } -QColor Theme::textColor() const +QColor Theme::color(ColorRole role) const { KColorScheme colorScheme(QPalette::Active, KColorScheme::Window, Theme::defaultTheme()->colorScheme()); - return colorScheme.foreground(KColorScheme::NormalText).color(); + + switch (role) { + case TextColor: + return colorScheme.foreground(KColorScheme::NormalText).color(); + break; + + case BackgroundColor: + return colorScheme.background().color(); + break; + } } -QColor Theme::backgroundColor() const -{ - KColorScheme colorScheme(QPalette::Active, KColorScheme::Window, Theme::defaultTheme()->colorScheme()); - return colorScheme.background().color(); -} - -void Theme::setFont(const QFont &font) +void Theme::setFont(const QFont &font, FontRole role) { + Q_UNUSED(role) d->generalFont = font; } -QFont Theme::font() const +QFont Theme::font(FontRole role) const { - //TODO: allow this to be overridden with a plasma specific font? + Q_UNUSED(role) return d->generalFont; } diff --git a/theme.h b/theme.h index d19969640..380c8b702 100644 --- a/theme.h +++ b/theme.h @@ -53,6 +53,17 @@ class PLASMA_EXPORT Theme : public QObject Q_PROPERTY( QString themeName READ themeName ) public: + enum ColorRole + { + TextColor = 0 /**< the text color to be used by items resting on the background */, + BackgroundColor /**< the default background color */ + }; + + enum FontRole + { + DefaultFont = 0 /**< The standard text font */ + }; + /** * Singleton pattern accessor **/ @@ -106,24 +117,26 @@ class PLASMA_EXPORT Theme : public QObject /** * Returns the text color to be used by items resting on the background + * + * @arg role which role (usage pattern) to get the color for */ - Q_INVOKABLE QColor textColor() const; - - /** - * Returns the background color to be used by items resting on the background - */ - Q_INVOKABLE QColor backgroundColor() const; + Q_INVOKABLE QColor color(ColorRole role) const; /** * Sets the default font to be used with themed items. Defaults to * the application wide default font. + * + * @arg font the new font + * @arg role which role (usage pattern) to set the font for */ - Q_INVOKABLE void setFont(const QFont &font); + Q_INVOKABLE void setFont(const QFont &font, FontRole role = DefaultFont); /** * Returns the font to be used by themed items + * + * @arg role which role (usage pattern) to get the font for */ - Q_INVOKABLE QFont font() const; + Q_INVOKABLE QFont font(FontRole role) const; /** * Returns the font metrics for the font to be used by themed items diff --git a/widgets/icon.cpp b/widgets/icon.cpp index ee1b191ec..266c3c679 100644 --- a/widgets/icon.cpp +++ b/widgets/icon.cpp @@ -79,8 +79,8 @@ Icon::Private::~Private() void Icon::readColors() { - d->textColor = Plasma::Theme::defaultTheme()->textColor(); - d->shadowColor = Plasma::Theme::defaultTheme()->backgroundColor(); + d->textColor = Plasma::Theme::defaultTheme()->color(Theme::TextColor); + d->shadowColor = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor); }