ColorGroup is part of Theme

This commit is contained in:
Marco Martin 2014-06-18 19:22:02 +02:00
parent c54d3d5538
commit b755bd1e32
11 changed files with 32 additions and 32 deletions

View File

@ -80,7 +80,7 @@ void CoreBindingsPlugin::registerTypes(const char *uri)
qmlRegisterType<Plasma::FrameSvgItem>(uri, 2, 0, "FrameSvgItem");
//qmlRegisterType<ThemeProxy>(uri, 2, 0, "Theme");
qmlRegisterType<Plasma::Theme>();
qmlRegisterUncreatableType<Plasma::Theme>(uri, 2, 0, "Theme", "It is not possible to instantiate Theme directly.");
qmlRegisterType<Plasma::DataSource>(uri, 2, 0, "DataSource");
qmlRegisterType<Plasma::DataModel>(uri, 2, 0, "DataModel");

View File

@ -40,7 +40,7 @@ IconItem::IconItem(QQuickItem *parent)
m_svgIcon(0),
m_smooth(false),
m_active(false),
m_colorGroup(Plasma::Svg::NormalColorGroup),
m_colorGroup(Plasma::Theme::NormalColorGroup),
m_animValue(0)
{
m_loadPixmapTimer.setSingleShot(true);
@ -150,7 +150,7 @@ QVariant IconItem::source() const
return m_source;
}
void IconItem::setColorGroup(Plasma::Svg::ColorGroup group)
void IconItem::setColorGroup(Plasma::Theme::ColorGroup group)
{
if (m_colorGroup == group) {
return;
@ -165,7 +165,7 @@ void IconItem::setColorGroup(Plasma::Svg::ColorGroup group)
emit colorGroupChanged();
}
Plasma::Svg::ColorGroup IconItem::colorGroup() const
Plasma::Theme::ColorGroup IconItem::colorGroup() const
{
return m_colorGroup;
}

View File

@ -36,7 +36,7 @@ class IconItem : public QQuickItem
Q_OBJECT
Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(Plasma::Svg::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged)
Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged)
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
@ -49,8 +49,8 @@ public:
void setSource(const QVariant &source);
QVariant source() const;
void setColorGroup(Plasma::Svg::ColorGroup group);
Plasma::Svg::ColorGroup colorGroup() const;
void setColorGroup(Plasma::Theme::ColorGroup group);
Plasma::Theme::ColorGroup colorGroup() const;
bool isActive() const;
void setActive(bool active);
@ -99,7 +99,7 @@ private:
QPixmap m_iconPixmap;
QPixmap m_oldIconPixmap;
Plasma::Svg::ColorGroup m_colorGroup;
Plasma::Theme::ColorGroup m_colorGroup;
//animation on pixmap change
QPropertyAnimation *m_animation;

View File

@ -244,7 +244,7 @@ Item {
width: valid? parent.height: 0
height: width
active: shadow.hasOverState && mouse.containsMouse
colorGroup: PlasmaCore.Svg.ButtonColorGroup
colorGroup: PlasmaCore.Theme.ButtonColorGroup
}
Label {

View File

@ -375,7 +375,7 @@ Item {
width: valid ? Math.min(Math.floor(parent.width/2) * 2, Math.floor(parent.height/2) * 2): 0
height: width
active: delegate.item.hasOverState && mouse.containsMouse
colorGroup: mouse.containsMouse || !button.flat ? PlasmaCore.Svg.ButtonColorGroup : PlasmaCore.Svg.NormalColorGroup
colorGroup: mouse.containsMouse || !button.flat ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.Theme.NormalColorGroup
}
Label {

View File

@ -106,7 +106,7 @@ public:
QSizeF size;
QSizeF naturalSize;
QChar styleCrc;
Svg::ColorGroup colorGroup;
Theme::ColorGroup colorGroup;
unsigned int lastModified;
qreal devicePixelRatio;
bool multipleImages : 1;

View File

@ -432,26 +432,26 @@ const QString ThemePrivate::processStyleSheet(const QString &css)
return stylesheet;
}
const QString ThemePrivate::svgStyleSheet(Plasma::Svg::ColorGroup group)
const QString ThemePrivate::svgStyleSheet(Plasma::Theme::ColorGroup group)
{
QString stylesheet = cachedSvgStyleSheets.value(group);
if (stylesheet.isEmpty()) {
QString skel = QStringLiteral(".ColorScheme-%1{color:%2;}");
switch (group) {
case Svg::ButtonColorGroup:
case Theme::ButtonColorGroup:
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%buttontextcolor"));
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%buttonbackgroundcolor"));
stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%buttonhovercolor"));
break;
case Svg::ViewColorGroup:
case Theme::ViewColorGroup:
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%viewtextcolor"));
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%viewbackgroundcolor"));
stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%viewhovercolor"));
break;
case Svg::ComplementaryColorGroup:
case Theme::ComplementaryColorGroup:
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%complementarytextcolor"));
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%complementarybackgroundcolor"));

View File

@ -78,7 +78,7 @@ public:
void processContrastSettings(KConfigBase *metadata);
const QString processStyleSheet(const QString &css);
const QString svgStyleSheet(Plasma::Svg::ColorGroup group);
const QString svgStyleSheet(Plasma::Theme::ColorGroup group);
QColor color(Theme::ColorRole role) const;
public Q_SLOTS:
@ -130,7 +130,7 @@ public:
QHash<QString, QPixmap> pixmapsToCache;
QHash<QString, QString> keysToCache;
QHash<QString, QString> idsToCache;
QHash<Svg::ColorGroup, QString> cachedSvgStyleSheets;
QHash<Theme::ColorGroup, QString> cachedSvgStyleSheets;
QHash<QString, QString> discoveries;
QTimer *pixmapSaveTimer;
QTimer *rectSaveTimer;

View File

@ -135,7 +135,7 @@ SvgPrivate::SvgPrivate(Svg *svg)
: q(svg),
renderer(0),
styleCrc(0),
colorGroup(Plasma::Svg::NormalColorGroup),
colorGroup(Plasma::Theme::NormalColorGroup),
lastModified(0),
devicePixelRatio(1.0),
multipleImages(false),
@ -686,7 +686,7 @@ qreal Svg::devicePixelRatio()
return d->devicePixelRatio;
}
void Svg::setColorGroup(Svg::ColorGroup group)
void Svg::setColorGroup(Theme::ColorGroup group)
{
if (d->colorGroup == group) {
return;
@ -697,7 +697,7 @@ void Svg::setColorGroup(Svg::ColorGroup group)
emit colorGroupChanged();
}
Svg::ColorGroup Svg::colorGroup() const
Theme::ColorGroup Svg::colorGroup() const
{
return d->colorGroup;
}

View File

@ -24,6 +24,7 @@
#include <QPixmap>
#include <plasma/plasma_export.h>
#include <plasma/theme.h>
class QPainter;
class QPoint;
@ -39,7 +40,6 @@ namespace Plasma
class FrameSvgPrivate;
class SvgPrivate;
class Theme;
/**
* @class Svg plasma/svg.h <Plasma/Svg>
@ -61,17 +61,9 @@ class PLASMA_EXPORT Svg : public QObject
Q_PROPERTY(bool multipleImages READ containsMultipleImages WRITE setContainsMultipleImages)
Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged)
Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache)
Q_PROPERTY(ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged);
Q_PROPERTY(Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged);
public:
enum ColorGroup {
NormalColorGroup = 0,
ButtonColorGroup = 1,
ViewColorGroup = 2,
ComplementaryColorGroup = 3
};
Q_ENUMS(ColorGroup)
/**
* Constructs an SVG object that implicitly shares and caches rendering.
*
@ -109,12 +101,12 @@ public:
* make them use ButtonTextColor/ButtonBackgroundColor
* or ViewTextColor/ViewBackgroundColor
*/
void setColorGroup(ColorGroup group);
void setColorGroup(Theme::ColorGroup group);
/**
* @return the color group for this Svg
*/
ColorGroup colorGroup() const;
Theme::ColorGroup colorGroup() const;
/**
* Returns a pixmap of the SVG represented by this object.

View File

@ -111,6 +111,14 @@ public:
ComplementaryFocusColor = 303 /** background color for "complementary" areas */
};
enum ColorGroup {
NormalColorGroup = 0,
ButtonColorGroup = 1,
ViewColorGroup = 2,
ComplementaryColorGroup = 3
};
Q_ENUMS(ColorGroup)
/**
* Default constructor. It will be the global theme configured in plasmarc
* @param parent the parent object