consolidate color and font methods into one method for each with a role enumeration
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=800334
This commit is contained in:
parent
7f09f15378
commit
d28a4c277a
@ -89,7 +89,7 @@ protected:
|
|||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
QColor wash = Plasma::Theme::defaultTheme()->backgroundColor();
|
QColor wash = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
|
||||||
wash.setAlphaF(.6);
|
wash.setAlphaF(.6);
|
||||||
painter->fillPath(parentItem()->shape(), wash);
|
painter->fillPath(parentItem()->shape(), wash);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
2
svg.cpp
2
svg.cpp
@ -173,7 +173,7 @@ class Svg::Private
|
|||||||
// Apply current color scheme if the svg asks for it
|
// Apply current color scheme if the svg asks for it
|
||||||
if (applyColors) {
|
if (applyColors) {
|
||||||
QImage itmp = p.toImage();
|
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);
|
p = p.fromImage(itmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
theme.cpp
20
theme.cpp
@ -260,26 +260,30 @@ KSharedConfigPtr Theme::colorScheme() const
|
|||||||
return d->colors;
|
return d->colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor Theme::textColor() const
|
QColor Theme::color(ColorRole role) const
|
||||||
{
|
{
|
||||||
KColorScheme colorScheme(QPalette::Active, KColorScheme::Window, Theme::defaultTheme()->colorScheme());
|
KColorScheme colorScheme(QPalette::Active, KColorScheme::Window, Theme::defaultTheme()->colorScheme());
|
||||||
|
|
||||||
|
switch (role) {
|
||||||
|
case TextColor:
|
||||||
return colorScheme.foreground(KColorScheme::NormalText).color();
|
return colorScheme.foreground(KColorScheme::NormalText).color();
|
||||||
}
|
break;
|
||||||
|
|
||||||
QColor Theme::backgroundColor() const
|
case BackgroundColor:
|
||||||
{
|
|
||||||
KColorScheme colorScheme(QPalette::Active, KColorScheme::Window, Theme::defaultTheme()->colorScheme());
|
|
||||||
return colorScheme.background().color();
|
return colorScheme.background().color();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theme::setFont(const QFont &font)
|
void Theme::setFont(const QFont &font, FontRole role)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(role)
|
||||||
d->generalFont = font;
|
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;
|
return d->generalFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
theme.h
29
theme.h
@ -53,6 +53,17 @@ class PLASMA_EXPORT Theme : public QObject
|
|||||||
Q_PROPERTY( QString themeName READ themeName )
|
Q_PROPERTY( QString themeName READ themeName )
|
||||||
|
|
||||||
public:
|
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
|
* 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
|
* 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;
|
Q_INVOKABLE QColor color(ColorRole role) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the background color to be used by items resting on the background
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QColor backgroundColor() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default font to be used with themed items. Defaults to
|
* Sets the default font to be used with themed items. Defaults to
|
||||||
* the application wide default font.
|
* 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
|
* 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
|
* Returns the font metrics for the font to be used by themed items
|
||||||
|
@ -79,8 +79,8 @@ Icon::Private::~Private()
|
|||||||
|
|
||||||
void Icon::readColors()
|
void Icon::readColors()
|
||||||
{
|
{
|
||||||
d->textColor = Plasma::Theme::defaultTheme()->textColor();
|
d->textColor = Plasma::Theme::defaultTheme()->color(Theme::TextColor);
|
||||||
d->shadowColor = Plasma::Theme::defaultTheme()->backgroundColor();
|
d->shadowColor = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user