From fa95680a51410347a35a9fd2d6827d009c14b295 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 9 Jun 2014 19:35:58 +0200 Subject: [PATCH] use color groups instead the Text and Background colors can become buttonText or ButtonBackground based on the svg property ColorGroup --- src/declarativeimports/core/iconitem.cpp | 31 ++++-- src/declarativeimports/core/iconitem.h | 13 ++- .../plasmacomponents/qml/Button.qml | 3 +- .../plasmacomponents/qml/ToolButton.qml | 1 + src/desktoptheme/CMakeLists.txt | 1 + .../breeze-complementary/CMakeLists.txt | 2 + src/desktoptheme/breeze-complementary/colors | 105 ++++++++++++++++++ .../breeze-complementary/metadata.desktop | 25 +++++ src/desktoptheme/breeze-dark/metadata.desktop | 3 + src/plasma/private/svg_p.h | 2 +- src/plasma/private/theme_p.cpp | 49 ++++---- src/plasma/private/theme_p.h | 10 +- src/plasma/svg.cpp | 31 +++--- src/plasma/svg.h | 27 +++-- 14 files changed, 227 insertions(+), 76 deletions(-) create mode 100644 src/desktoptheme/breeze-complementary/CMakeLists.txt create mode 100644 src/desktoptheme/breeze-complementary/colors create mode 100644 src/desktoptheme/breeze-complementary/metadata.desktop diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp index e235f25f2..384017d4a 100644 --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -32,8 +32,6 @@ #include #include -#include - #include "fadingnode_p.h" #include "svgtexturenode.h" @@ -42,6 +40,7 @@ IconItem::IconItem(QQuickItem *parent) m_svgIcon(0), m_smooth(false), m_active(false), + m_svgColorGroup(Plasma::Svg::NormalColorGroup), m_animValue(0) { m_loadPixmapTimer.setSingleShot(true); @@ -96,6 +95,7 @@ void IconItem::setSource(const QVariant &source) } else if (source.canConvert()) { if (!m_svgIcon) { m_svgIcon = new Plasma::Svg(this); + m_svgIcon->setColorGroup(m_svgColorGroup); } //try as a svg icon m_svgIcon->setImagePath("icons/" + source.toString().split("-").first()); @@ -152,6 +152,26 @@ QVariant IconItem::source() const return m_source; } +void IconItem::setSvgColorGroup(Plasma::Svg::ColorGroup group) +{ + if (m_svgColorGroup == group) { + return; + } + + m_svgColorGroup = group; + + if (m_svgIcon) { + m_svgIcon->setColorGroup(group); + } + + emit svgColorGroupChanged(); +} + +Plasma::Svg::ColorGroup IconItem::svgColorGroup() const +{ + return m_svgColorGroup; +} + bool IconItem::isActive() const { return m_active; @@ -163,13 +183,6 @@ void IconItem::setActive(bool active) return; } - if (m_svgIcon) { - if (active) { - m_svgIcon->setStyleHints(Plasma::Svg::Inverted|Plasma::Svg::Highlighted); - } else { - m_svgIcon->setStyleHints(Plasma::Svg::Normal); - } - } m_active = active; m_loadPixmapTimer.start(); emit activeChanged(); diff --git a/src/declarativeimports/core/iconitem.h b/src/declarativeimports/core/iconitem.h index 8d087eb39..5e3f963e8 100644 --- a/src/declarativeimports/core/iconitem.h +++ b/src/declarativeimports/core/iconitem.h @@ -27,18 +27,16 @@ #include #include -class QPropertyAnimation; +#include -namespace Plasma -{ -class Svg; -} +class QPropertyAnimation; class IconItem : public QQuickItem { Q_OBJECT Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(Plasma::Svg::ColorGroup svgColorGroup READ svgColorGroup WRITE setSvgColorGroup NOTIFY svgColorGroupChanged) 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) @@ -51,6 +49,9 @@ public: void setSource(const QVariant &source); QVariant source() const; + void setSvgColorGroup(Plasma::Svg::ColorGroup group); + Plasma::Svg::ColorGroup svgColorGroup() const; + bool isActive() const; void setActive(bool active); @@ -69,6 +70,7 @@ Q_SIGNALS: void sourceChanged(); void smoothChanged(); void validChanged(); + void svgColorGroupChanged(); private Q_SLOTS: void loadPixmap(); @@ -97,6 +99,7 @@ private: QPixmap m_iconPixmap; QPixmap m_oldIconPixmap; + Plasma::Svg::ColorGroup m_svgColorGroup; //animation on pixmap change QPropertyAnimation *m_animation; diff --git a/src/declarativeimports/plasmacomponents/qml/Button.qml b/src/declarativeimports/plasmacomponents/qml/Button.qml index 2eba04c67..c0f2b99d9 100644 --- a/src/declarativeimports/plasmacomponents/qml/Button.qml +++ b/src/declarativeimports/plasmacomponents/qml/Button.qml @@ -244,6 +244,7 @@ Item { width: valid? parent.height: 0 height: width active: shadow.hasOverState && mouse.containsMouse + svgColorGroup: PlasmaCore.Svg.ButtonColorGroup } Label { @@ -255,8 +256,6 @@ Item { verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } - - } MouseArea { diff --git a/src/declarativeimports/plasmacomponents/qml/ToolButton.qml b/src/declarativeimports/plasmacomponents/qml/ToolButton.qml index c9a765606..1740c49e3 100644 --- a/src/declarativeimports/plasmacomponents/qml/ToolButton.qml +++ b/src/declarativeimports/plasmacomponents/qml/ToolButton.qml @@ -363,6 +363,7 @@ Item { width: valid ? Math.min(parent.width, parent.height): 0 height: width active: delegate.item.hasOverState && mouse.containsMouse + svgColorGroup: mouse.containsMouse || !button.flat ? PlasmaCore.Svg.ButtonColorGroup : PlasmaCore.Svg.NormalColorGroup } Label { diff --git a/src/desktoptheme/CMakeLists.txt b/src/desktoptheme/CMakeLists.txt index 3087c1779..3efaab6e9 100644 --- a/src/desktoptheme/CMakeLists.txt +++ b/src/desktoptheme/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory( oxygen ) add_subdirectory( air ) add_subdirectory( breeze ) add_subdirectory( breeze-dark ) +add_subdirectory( breeze-complementary ) diff --git a/src/desktoptheme/breeze-complementary/CMakeLists.txt b/src/desktoptheme/breeze-complementary/CMakeLists.txt new file mode 100644 index 000000000..0941356dc --- /dev/null +++ b/src/desktoptheme/breeze-complementary/CMakeLists.txt @@ -0,0 +1,2 @@ + +install(FILES colors metadata.desktop DESTINATION ${PLASMA_DATA_INSTALL_DIR}/desktoptheme/breeze-complementary/) diff --git a/src/desktoptheme/breeze-complementary/colors b/src/desktoptheme/breeze-complementary/colors new file mode 100644 index 000000000..f0c3e6953 --- /dev/null +++ b/src/desktoptheme/breeze-complementary/colors @@ -0,0 +1,105 @@ +[ColorEffects:Disabled] +Color=56,56,56 +ColorAmount=0 +ColorEffect=0 +ContrastAmount=0.65 +ContrastEffect=1 +IntensityAmount=0.1 +IntensityEffect=2 + +[ColorEffects:Inactive] +ChangeSelectionColor=true +Color=112,111,110 +ColorAmount=0.025 +ColorEffect=2 +ContrastAmount=0.1 +ContrastEffect=2 +Enable=false +IntensityAmount=0 +IntensityEffect=0 + +[Colors:Button] +BackgroundAlternate=224,223,222 +BackgroundNormal=239,240,241 +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=49,54,59 +ForegroundPositive=17,209,22 +ForegroundVisited=61,174,230 + +[Colors:Selection] +BackgroundAlternate=48,138,183 +BackgroundNormal=61,174,230 +DecorationFocus=30,146,255 +DecorationHover=61,174,230 +ForegroundActive=246,116,0 +ForegroundInactive=146,204,230 +ForegroundLink=252,252,252 +ForegroundNegative=237,21,21 +ForegroundNeutral=201,206,59 +ForegroundNormal=252,252,252 +ForegroundPositive=17,209,22 +ForegroundVisited=252,252,252 + +[Colors:Tooltip] +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 + +[Colors:View] +BackgroundAlternate=248,247,246 +BackgroundNormal=252,252,252 +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=49,54,59 +ForegroundPositive=17,209,22 +ForegroundVisited=61,174,230 + +[Colors:Window] +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 +shadeSortColumn=true + +[KDE] +contrast=7 + +[WM] +activeBackground=61,174,230 +activeBlend=252,252,252 +activeForeground=252,252,252 +inactiveBackground=123,124,126 +inactiveBlend=123,124,126 +inactiveForeground=252,252,252 diff --git a/src/desktoptheme/breeze-complementary/metadata.desktop b/src/desktoptheme/breeze-complementary/metadata.desktop new file mode 100644 index 000000000..41935fa97 --- /dev/null +++ b/src/desktoptheme/breeze-complementary/metadata.desktop @@ -0,0 +1,25 @@ +[Desktop Entry] +Name=Breeze Complementary + + +X-KDE-PluginInfo-Author=KDE Visual Design Group +X-KDE-PluginInfo-Email=kde-artists@kde.org +X-KDE-PluginInfo-Name=breeze-complementary +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://plasma.kde.org +X-KDE-PluginInfo-Category= +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-EnabledByDefault=true + +[Wallpaper] +defaultWallpaperTheme=Elarun +defaultFileSuffix=.png +defaultWidth=2560 +defaultHeight=1600 + +[ContrastEffect] +enabled=true +contrast=0.2 +intensity=0.4 +saturation=1.7 \ No newline at end of file diff --git a/src/desktoptheme/breeze-dark/metadata.desktop b/src/desktoptheme/breeze-dark/metadata.desktop index 1026bb527..aff977a24 100644 --- a/src/desktoptheme/breeze-dark/metadata.desktop +++ b/src/desktoptheme/breeze-dark/metadata.desktop @@ -38,3 +38,6 @@ defaultHeight=1600 [ContrastEffect] enabled=true +contrast=0.2 +intensity=0.4 +saturation=1.7 diff --git a/src/plasma/private/svg_p.h b/src/plasma/private/svg_p.h index 5e4846c0e..cb5039f92 100644 --- a/src/plasma/private/svg_p.h +++ b/src/plasma/private/svg_p.h @@ -106,7 +106,7 @@ public: QSizeF size; QSizeF naturalSize; QChar styleCrc; - Svg::StyleHints styleHints; + Svg::ColorGroup colorGroup; unsigned int lastModified; qreal devicePixelRatio; bool multipleImages : 1; diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index 72e1872f4..7714cb00b 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -314,7 +314,8 @@ void ThemePrivate::discardCache(CacheTypes caches) pixmapCache = 0; } - cachedStyleSheets.clear(); + cachedDefaultStyleSheet = QString(); + cachedSvgStyleSheets.clear(); if (caches & SvgElementsCache) { discoveries.clear(); @@ -373,7 +374,7 @@ const QString ThemePrivate::processStyleSheet(const QString &css) { QString stylesheet; if (css.isEmpty()) { - stylesheet = cachedStyleSheets.value(DEFAULTSTYLE); + stylesheet = cachedDefaultStyleSheet; if (stylesheet.isEmpty()) { stylesheet = QStringLiteral("\n\ body {\n\ @@ -386,8 +387,7 @@ const QString ThemePrivate::processStyleSheet(const QString &css) a:visited { color: %visitedlink; }\n\ a:hover { color: %hoveredlink; text-decoration: none; }\n\ "); - stylesheet = processStyleSheet(stylesheet); - cachedStyleSheets.insert(DEFAULTSTYLE, stylesheet); + stylesheet = cachedDefaultStyleSheet = processStyleSheet(stylesheet); } return stylesheet; @@ -427,31 +427,32 @@ const QString ThemePrivate::processStyleSheet(const QString &css) return stylesheet; } -const QString ThemePrivate::svgStyleSheet(Plasma::Svg::StyleHints hints) -{qWarning()<<"BBBBB"< > invalidElements; QHash pixmapsToCache; QHash keysToCache; QHash idsToCache; - QHash cachedStyleSheets; + QHash cachedSvgStyleSheets; QHash discoveries; QTimer *pixmapSaveTimer; QTimer *rectSaveTimer; diff --git a/src/plasma/svg.cpp b/src/plasma/svg.cpp index 63eb3ef00..d34829c41 100644 --- a/src/plasma/svg.cpp +++ b/src/plasma/svg.cpp @@ -128,14 +128,14 @@ bool SharedSvgRenderer::load( } #define QLSEP QLatin1Char('_') -#define CACHE_ID_WITH_SIZE(size, id, devicePixelRatio, styleHints) QString::number(int(size.width())) % QLSEP % QString::number(int(size.height())) % QLSEP % id % QLSEP % QString::number(int(devicePixelRatio)) % QLSEP % QString::number(styleHints) -#define CACHE_ID_NATURAL_SIZE(id, devicePixelRatio, styleHints) QLatin1Literal("Natural") % QLSEP % id % QLSEP % QString::number(int(devicePixelRatio)) % QLSEP % QString::number(styleHints) +#define CACHE_ID_WITH_SIZE(size, id, devicePixelRatio) QString::number(int(size.width())) % QLSEP % QString::number(int(size.height())) % QLSEP % id % QLSEP % QString::number(int(devicePixelRatio)) +#define CACHE_ID_NATURAL_SIZE(id, devicePixelRatio) QLatin1Literal("Natural") % QLSEP % id % QLSEP % QString::number(int(devicePixelRatio)) SvgPrivate::SvgPrivate(Svg *svg) : q(svg), renderer(0), styleCrc(0), - styleHints(Plasma::Svg::Normal), + colorGroup(Plasma::Svg::NormalColorGroup), lastModified(0), devicePixelRatio(1.0), multipleImages(false), @@ -156,17 +156,16 @@ SvgPrivate::~SvgPrivate() QString SvgPrivate::cacheId(const QString &elementId) { if (size.isValid() && size != naturalSize) { - //the size won't change with another style - return CACHE_ID_WITH_SIZE(size, elementId, devicePixelRatio, 0); + return CACHE_ID_WITH_SIZE(size, elementId, devicePixelRatio); } else { - return CACHE_ID_NATURAL_SIZE(elementId, devicePixelRatio, 0); + return CACHE_ID_NATURAL_SIZE(elementId, devicePixelRatio); } } //This function is meant for the pixmap cache QString SvgPrivate::cachePath(const QString &path, const QSize &size) { - return CACHE_ID_WITH_SIZE(size, path, devicePixelRatio, styleHints); + return CACHE_ID_WITH_SIZE(size, path, devicePixelRatio) % QLSEP % QString::number(colorGroup); } bool SvgPrivate::setImagePath(const QString &imagePath) @@ -280,7 +279,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, const QSizeF &s) if (elementsWithSizeHints.isEmpty()) { // Fetch all size hinted element ids from the theme's rect cache // and store them locally. - QRegExp sizeHintedKeyExpr(CACHE_ID_NATURAL_SIZE("(\\d+)-(\\d+)-(.+)", devicePixelRatio, 0)); + QRegExp sizeHintedKeyExpr(CACHE_ID_NATURAL_SIZE("(\\d+)-(\\d+)-(.+)", devicePixelRatio)); foreach (const QString &key, cacheAndColorsTheme()->listCachedRectKeys(path)) { if (sizeHintedKeyExpr.exactMatch(key)) { @@ -417,7 +416,7 @@ void SvgPrivate::createRenderer() //qDebug() << "FAIL! **************************"; //qDebug() << path << "**"; - QString styleSheet = cacheAndColorsTheme()->d->svgStyleSheet(styleHints); + QString styleSheet = cacheAndColorsTheme()->d->svgStyleSheet(colorGroup); styleCrc = qChecksum(styleSheet.toUtf8(), styleSheet.size()); QHash::const_iterator it = s_renderers.constFind(styleCrc + path); @@ -440,7 +439,7 @@ void SvgPrivate::createRenderer() const QString &elementId = i.key(); const QRectF &elementRect = i.value(); - const QString cacheId = CACHE_ID_NATURAL_SIZE(elementId, devicePixelRatio, styleHints); + const QString cacheId = CACHE_ID_NATURAL_SIZE(elementId, devicePixelRatio); localRectCache.insert(cacheId, elementRect); cacheAndColorsTheme()->insertIntoRectsCache(path, cacheId, elementRect); } @@ -687,20 +686,20 @@ qreal Svg::devicePixelRatio() return d->devicePixelRatio; } -void Svg::setStyleHints(Svg::StyleHints hints) +void Svg::setColorGroup(Svg::ColorGroup group) { - if (d->styleHints == hints) { + if (d->colorGroup == group) { return; } - d->styleHints = hints; + d->colorGroup = group; d->renderer = 0; - emit styleHintsChanged(); + emit colorGroupChanged(); } -Svg::StyleHints Svg::styleHints() const +Svg::ColorGroup Svg::colorGroup() const { - return d->styleHints; + return d->colorGroup; } QPixmap Svg::pixmap(const QString &elementID) diff --git a/src/plasma/svg.h b/src/plasma/svg.h index 82db7d279..6da9d49ba 100644 --- a/src/plasma/svg.h +++ b/src/plasma/svg.h @@ -61,15 +61,15 @@ 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(StyleHints styleHints READ styleHints WRITE setStyleHints NOTIFY styleHintsChanged); + Q_PROPERTY(ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged); public: - enum StyleHint{ - Normal = 0, - Inverted = 1, - Highlighted = 2 + enum ColorGroup { + NormalColorGroup = 0, + ButtonColorGroup = 1, + ViewColorGroup = 2 }; - Q_DECLARE_FLAGS(StyleHints, StyleHint) + Q_ENUMS(ColorGroup) /** * Constructs an SVG object that implicitly shares and caches rendering. @@ -101,8 +101,8 @@ public: */ qreal devicePixelRatio(); - void setStyleHints(StyleHints hint); - StyleHints styleHints() const; + void setColorGroup(ColorGroup group); + ColorGroup colorGroup() const; /** * Returns a pixmap of the SVG represented by this object. @@ -410,9 +410,14 @@ Q_SIGNALS: void imagePathChanged(); /** - * Emitted whenever the style hints are changed. + * Emitted whenever the color hint has changed. */ - void styleHintsChanged(); + void colorHintChanged(); + + /** + * Emitted whenever the color group has changed. + */ + void colorGroupChanged(); private: SvgPrivate *const d; @@ -428,7 +433,5 @@ private: } // Plasma namespace -Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Svg::StyleHints) - #endif // multiple inclusion guard