use color groups instead
the Text and Background colors can become buttonText or ButtonBackground based on the svg property ColorGroup
This commit is contained in:
parent
cac2704d50
commit
fa95680a51
@ -32,8 +32,6 @@
|
|||||||
#include <kiconloader.h>
|
#include <kiconloader.h>
|
||||||
#include <kiconeffect.h>
|
#include <kiconeffect.h>
|
||||||
|
|
||||||
#include <plasma/svg.h>
|
|
||||||
|
|
||||||
#include "fadingnode_p.h"
|
#include "fadingnode_p.h"
|
||||||
#include "svgtexturenode.h"
|
#include "svgtexturenode.h"
|
||||||
|
|
||||||
@ -42,6 +40,7 @@ IconItem::IconItem(QQuickItem *parent)
|
|||||||
m_svgIcon(0),
|
m_svgIcon(0),
|
||||||
m_smooth(false),
|
m_smooth(false),
|
||||||
m_active(false),
|
m_active(false),
|
||||||
|
m_svgColorGroup(Plasma::Svg::NormalColorGroup),
|
||||||
m_animValue(0)
|
m_animValue(0)
|
||||||
{
|
{
|
||||||
m_loadPixmapTimer.setSingleShot(true);
|
m_loadPixmapTimer.setSingleShot(true);
|
||||||
@ -96,6 +95,7 @@ void IconItem::setSource(const QVariant &source)
|
|||||||
} else if (source.canConvert<QString>()) {
|
} else if (source.canConvert<QString>()) {
|
||||||
if (!m_svgIcon) {
|
if (!m_svgIcon) {
|
||||||
m_svgIcon = new Plasma::Svg(this);
|
m_svgIcon = new Plasma::Svg(this);
|
||||||
|
m_svgIcon->setColorGroup(m_svgColorGroup);
|
||||||
}
|
}
|
||||||
//try as a svg icon
|
//try as a svg icon
|
||||||
m_svgIcon->setImagePath("icons/" + source.toString().split("-").first());
|
m_svgIcon->setImagePath("icons/" + source.toString().split("-").first());
|
||||||
@ -152,6 +152,26 @@ QVariant IconItem::source() const
|
|||||||
return m_source;
|
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
|
bool IconItem::isActive() const
|
||||||
{
|
{
|
||||||
return m_active;
|
return m_active;
|
||||||
@ -163,13 +183,6 @@ void IconItem::setActive(bool active)
|
|||||||
return;
|
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_active = active;
|
||||||
m_loadPixmapTimer.start();
|
m_loadPixmapTimer.start();
|
||||||
emit activeChanged();
|
emit activeChanged();
|
||||||
|
@ -27,18 +27,16 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
class QPropertyAnimation;
|
#include <plasma/svg.h>
|
||||||
|
|
||||||
namespace Plasma
|
class QPropertyAnimation;
|
||||||
{
|
|
||||||
class Svg;
|
|
||||||
}
|
|
||||||
|
|
||||||
class IconItem : public QQuickItem
|
class IconItem : public QQuickItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged)
|
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 smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
|
||||||
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
|
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
|
||||||
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
|
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
|
||||||
@ -51,6 +49,9 @@ public:
|
|||||||
void setSource(const QVariant &source);
|
void setSource(const QVariant &source);
|
||||||
QVariant source() const;
|
QVariant source() const;
|
||||||
|
|
||||||
|
void setSvgColorGroup(Plasma::Svg::ColorGroup group);
|
||||||
|
Plasma::Svg::ColorGroup svgColorGroup() const;
|
||||||
|
|
||||||
bool isActive() const;
|
bool isActive() const;
|
||||||
void setActive(bool active);
|
void setActive(bool active);
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ Q_SIGNALS:
|
|||||||
void sourceChanged();
|
void sourceChanged();
|
||||||
void smoothChanged();
|
void smoothChanged();
|
||||||
void validChanged();
|
void validChanged();
|
||||||
|
void svgColorGroupChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void loadPixmap();
|
void loadPixmap();
|
||||||
@ -97,6 +99,7 @@ private:
|
|||||||
QPixmap m_iconPixmap;
|
QPixmap m_iconPixmap;
|
||||||
QPixmap m_oldIconPixmap;
|
QPixmap m_oldIconPixmap;
|
||||||
|
|
||||||
|
Plasma::Svg::ColorGroup m_svgColorGroup;
|
||||||
|
|
||||||
//animation on pixmap change
|
//animation on pixmap change
|
||||||
QPropertyAnimation *m_animation;
|
QPropertyAnimation *m_animation;
|
||||||
|
@ -244,6 +244,7 @@ Item {
|
|||||||
width: valid? parent.height: 0
|
width: valid? parent.height: 0
|
||||||
height: width
|
height: width
|
||||||
active: shadow.hasOverState && mouse.containsMouse
|
active: shadow.hasOverState && mouse.containsMouse
|
||||||
|
svgColorGroup: PlasmaCore.Svg.ButtonColorGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@ -255,8 +256,6 @@ Item {
|
|||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
@ -363,6 +363,7 @@ Item {
|
|||||||
width: valid ? Math.min(parent.width, parent.height): 0
|
width: valid ? Math.min(parent.width, parent.height): 0
|
||||||
height: width
|
height: width
|
||||||
active: delegate.item.hasOverState && mouse.containsMouse
|
active: delegate.item.hasOverState && mouse.containsMouse
|
||||||
|
svgColorGroup: mouse.containsMouse || !button.flat ? PlasmaCore.Svg.ButtonColorGroup : PlasmaCore.Svg.NormalColorGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
@ -2,3 +2,4 @@ add_subdirectory( oxygen )
|
|||||||
add_subdirectory( air )
|
add_subdirectory( air )
|
||||||
add_subdirectory( breeze )
|
add_subdirectory( breeze )
|
||||||
add_subdirectory( breeze-dark )
|
add_subdirectory( breeze-dark )
|
||||||
|
add_subdirectory( breeze-complementary )
|
||||||
|
2
src/desktoptheme/breeze-complementary/CMakeLists.txt
Normal file
2
src/desktoptheme/breeze-complementary/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
install(FILES colors metadata.desktop DESTINATION ${PLASMA_DATA_INSTALL_DIR}/desktoptheme/breeze-complementary/)
|
105
src/desktoptheme/breeze-complementary/colors
Normal file
105
src/desktoptheme/breeze-complementary/colors
Normal file
@ -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
|
25
src/desktoptheme/breeze-complementary/metadata.desktop
Normal file
25
src/desktoptheme/breeze-complementary/metadata.desktop
Normal file
@ -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
|
@ -38,3 +38,6 @@ defaultHeight=1600
|
|||||||
|
|
||||||
[ContrastEffect]
|
[ContrastEffect]
|
||||||
enabled=true
|
enabled=true
|
||||||
|
contrast=0.2
|
||||||
|
intensity=0.4
|
||||||
|
saturation=1.7
|
||||||
|
@ -106,7 +106,7 @@ public:
|
|||||||
QSizeF size;
|
QSizeF size;
|
||||||
QSizeF naturalSize;
|
QSizeF naturalSize;
|
||||||
QChar styleCrc;
|
QChar styleCrc;
|
||||||
Svg::StyleHints styleHints;
|
Svg::ColorGroup colorGroup;
|
||||||
unsigned int lastModified;
|
unsigned int lastModified;
|
||||||
qreal devicePixelRatio;
|
qreal devicePixelRatio;
|
||||||
bool multipleImages : 1;
|
bool multipleImages : 1;
|
||||||
|
@ -314,7 +314,8 @@ void ThemePrivate::discardCache(CacheTypes caches)
|
|||||||
pixmapCache = 0;
|
pixmapCache = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cachedStyleSheets.clear();
|
cachedDefaultStyleSheet = QString();
|
||||||
|
cachedSvgStyleSheets.clear();
|
||||||
|
|
||||||
if (caches & SvgElementsCache) {
|
if (caches & SvgElementsCache) {
|
||||||
discoveries.clear();
|
discoveries.clear();
|
||||||
@ -373,7 +374,7 @@ const QString ThemePrivate::processStyleSheet(const QString &css)
|
|||||||
{
|
{
|
||||||
QString stylesheet;
|
QString stylesheet;
|
||||||
if (css.isEmpty()) {
|
if (css.isEmpty()) {
|
||||||
stylesheet = cachedStyleSheets.value(DEFAULTSTYLE);
|
stylesheet = cachedDefaultStyleSheet;
|
||||||
if (stylesheet.isEmpty()) {
|
if (stylesheet.isEmpty()) {
|
||||||
stylesheet = QStringLiteral("\n\
|
stylesheet = QStringLiteral("\n\
|
||||||
body {\n\
|
body {\n\
|
||||||
@ -386,8 +387,7 @@ const QString ThemePrivate::processStyleSheet(const QString &css)
|
|||||||
a:visited { color: %visitedlink; }\n\
|
a:visited { color: %visitedlink; }\n\
|
||||||
a:hover { color: %hoveredlink; text-decoration: none; }\n\
|
a:hover { color: %hoveredlink; text-decoration: none; }\n\
|
||||||
");
|
");
|
||||||
stylesheet = processStyleSheet(stylesheet);
|
stylesheet = cachedDefaultStyleSheet = processStyleSheet(stylesheet);
|
||||||
cachedStyleSheets.insert(DEFAULTSTYLE, stylesheet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return stylesheet;
|
return stylesheet;
|
||||||
@ -427,31 +427,32 @@ const QString ThemePrivate::processStyleSheet(const QString &css)
|
|||||||
return stylesheet;
|
return stylesheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString ThemePrivate::svgStyleSheet(Plasma::Svg::StyleHints hints)
|
const QString ThemePrivate::svgStyleSheet(Plasma::Svg::ColorGroup group)
|
||||||
{qWarning()<<"BBBBB"<<hints<<(SVGSTYLE+(int)hints);
|
{
|
||||||
QString stylesheet = cachedStyleSheets.value(SVGSTYLE+(int)hints);
|
QString stylesheet = cachedSvgStyleSheets.value(group);
|
||||||
if (stylesheet.isEmpty()) {
|
if (stylesheet.isEmpty()) {
|
||||||
QString skel = QStringLiteral(".ColorScheme-%1{color:%2;}");
|
QString skel = QStringLiteral(".ColorScheme-%1{color:%2;}");
|
||||||
|
|
||||||
if ((hints & Svg::Highlighted) && (hints & Svg::Inverted)) {
|
switch (group) {
|
||||||
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%highlightcolor"));
|
case Svg::ButtonColorGroup:
|
||||||
} else if ((hints & Svg::Inverted) || (hints & Svg::Highlighted)) {
|
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%buttontextcolor"));
|
||||||
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%backgroundcolor"));
|
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%buttonbackgroundcolor"));
|
||||||
//Normal
|
|
||||||
} else {
|
stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%buttonhovercolor"));
|
||||||
|
break;
|
||||||
|
case Svg::ViewColorGroup:
|
||||||
|
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%viewtextcolor"));
|
||||||
|
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%viewbackgroundcolor"));
|
||||||
|
|
||||||
|
stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%viewhovercolor"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%textcolor"));
|
stylesheet += skel.arg(QStringLiteral("Text"), QStringLiteral("%textcolor"));
|
||||||
}
|
|
||||||
|
|
||||||
if ((hints & Svg::Highlighted) && !(hints & Svg::Inverted)) {
|
|
||||||
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%highlightcolor"));
|
|
||||||
} else if (hints & Svg::Inverted) {
|
|
||||||
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%textcolor"));
|
|
||||||
//Normal
|
|
||||||
} else {
|
|
||||||
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%backgroundcolor"));
|
stylesheet += skel.arg(QStringLiteral("Background"), QStringLiteral("%backgroundcolor"));
|
||||||
|
|
||||||
|
stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%highlightcolor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%highlightcolor"));
|
|
||||||
|
|
||||||
stylesheet += skel.arg(QStringLiteral("ButtonText"), QStringLiteral("%buttontextcolor"));
|
stylesheet += skel.arg(QStringLiteral("ButtonText"), QStringLiteral("%buttontextcolor"));
|
||||||
stylesheet += skel.arg(QStringLiteral("ButtonBackground"), QStringLiteral("%buttonbackgroundcolor"));
|
stylesheet += skel.arg(QStringLiteral("ButtonBackground"), QStringLiteral("%buttonbackgroundcolor"));
|
||||||
@ -464,7 +465,7 @@ const QString ThemePrivate::svgStyleSheet(Plasma::Svg::StyleHints hints)
|
|||||||
stylesheet += skel.arg(QStringLiteral("ViewFocus"), QStringLiteral("%viewfocuscolor"));
|
stylesheet += skel.arg(QStringLiteral("ViewFocus"), QStringLiteral("%viewfocuscolor"));
|
||||||
|
|
||||||
stylesheet = processStyleSheet(stylesheet);
|
stylesheet = processStyleSheet(stylesheet);
|
||||||
cachedStyleSheets.insert(SVGSTYLE+(int)hints, stylesheet);
|
cachedSvgStyleSheets.insert(group, stylesheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stylesheet;
|
return stylesheet;
|
||||||
@ -516,7 +517,7 @@ QColor ThemePrivate::color(Theme::ColorRole role) const
|
|||||||
return colorScheme.foreground(KColorScheme::NormalText).color();
|
return colorScheme.foreground(KColorScheme::NormalText).color();
|
||||||
|
|
||||||
case Theme::HighlightColor:
|
case Theme::HighlightColor:
|
||||||
return colorScheme.decoration(KColorScheme::FocusColor).color();
|
return colorScheme.decoration(KColorScheme::HoverColor).color();
|
||||||
|
|
||||||
case Theme::BackgroundColor:
|
case Theme::BackgroundColor:
|
||||||
return colorScheme.background(KColorScheme::NormalBackground).color();
|
return colorScheme.background(KColorScheme::NormalBackground).color();
|
||||||
|
@ -50,11 +50,6 @@ class Theme;
|
|||||||
static const int DEFAULT_WALLPAPER_WIDTH = 1920;
|
static const int DEFAULT_WALLPAPER_WIDTH = 1920;
|
||||||
static const int DEFAULT_WALLPAPER_HEIGHT = 1200;
|
static const int DEFAULT_WALLPAPER_HEIGHT = 1200;
|
||||||
|
|
||||||
enum styles {
|
|
||||||
DEFAULTSTYLE,
|
|
||||||
SVGSTYLE
|
|
||||||
};
|
|
||||||
|
|
||||||
enum CacheType {
|
enum CacheType {
|
||||||
NoCache = 0,
|
NoCache = 0,
|
||||||
PixmapCache = 1,
|
PixmapCache = 1,
|
||||||
@ -83,7 +78,7 @@ public:
|
|||||||
void processContrastSettings(KConfigBase *metadata);
|
void processContrastSettings(KConfigBase *metadata);
|
||||||
|
|
||||||
const QString processStyleSheet(const QString &css);
|
const QString processStyleSheet(const QString &css);
|
||||||
const QString svgStyleSheet(Plasma::Svg::StyleHints hints);
|
const QString svgStyleSheet(Plasma::Svg::ColorGroup group);
|
||||||
QColor color(Theme::ColorRole role) const;
|
QColor color(Theme::ColorRole role) const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
@ -130,11 +125,12 @@ public:
|
|||||||
int defaultWallpaperHeight;
|
int defaultWallpaperHeight;
|
||||||
KImageCache *pixmapCache;
|
KImageCache *pixmapCache;
|
||||||
KSharedConfigPtr svgElementsCache;
|
KSharedConfigPtr svgElementsCache;
|
||||||
|
QString cachedDefaultStyleSheet;
|
||||||
QHash<QString, QSet<QString> > invalidElements;
|
QHash<QString, QSet<QString> > invalidElements;
|
||||||
QHash<QString, QPixmap> pixmapsToCache;
|
QHash<QString, QPixmap> pixmapsToCache;
|
||||||
QHash<QString, QString> keysToCache;
|
QHash<QString, QString> keysToCache;
|
||||||
QHash<QString, QString> idsToCache;
|
QHash<QString, QString> idsToCache;
|
||||||
QHash<int, QString> cachedStyleSheets;
|
QHash<Svg::ColorGroup, QString> cachedSvgStyleSheets;
|
||||||
QHash<QString, QString> discoveries;
|
QHash<QString, QString> discoveries;
|
||||||
QTimer *pixmapSaveTimer;
|
QTimer *pixmapSaveTimer;
|
||||||
QTimer *rectSaveTimer;
|
QTimer *rectSaveTimer;
|
||||||
|
@ -128,14 +128,14 @@ bool SharedSvgRenderer::load(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define QLSEP QLatin1Char('_')
|
#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_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, styleHints) QLatin1Literal("Natural") % QLSEP % id % QLSEP % QString::number(int(devicePixelRatio)) % QLSEP % QString::number(styleHints)
|
#define CACHE_ID_NATURAL_SIZE(id, devicePixelRatio) QLatin1Literal("Natural") % QLSEP % id % QLSEP % QString::number(int(devicePixelRatio))
|
||||||
|
|
||||||
SvgPrivate::SvgPrivate(Svg *svg)
|
SvgPrivate::SvgPrivate(Svg *svg)
|
||||||
: q(svg),
|
: q(svg),
|
||||||
renderer(0),
|
renderer(0),
|
||||||
styleCrc(0),
|
styleCrc(0),
|
||||||
styleHints(Plasma::Svg::Normal),
|
colorGroup(Plasma::Svg::NormalColorGroup),
|
||||||
lastModified(0),
|
lastModified(0),
|
||||||
devicePixelRatio(1.0),
|
devicePixelRatio(1.0),
|
||||||
multipleImages(false),
|
multipleImages(false),
|
||||||
@ -156,17 +156,16 @@ SvgPrivate::~SvgPrivate()
|
|||||||
QString SvgPrivate::cacheId(const QString &elementId)
|
QString SvgPrivate::cacheId(const QString &elementId)
|
||||||
{
|
{
|
||||||
if (size.isValid() && size != naturalSize) {
|
if (size.isValid() && size != naturalSize) {
|
||||||
//the size won't change with another style
|
return CACHE_ID_WITH_SIZE(size, elementId, devicePixelRatio);
|
||||||
return CACHE_ID_WITH_SIZE(size, elementId, devicePixelRatio, 0);
|
|
||||||
} else {
|
} else {
|
||||||
return CACHE_ID_NATURAL_SIZE(elementId, devicePixelRatio, 0);
|
return CACHE_ID_NATURAL_SIZE(elementId, devicePixelRatio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//This function is meant for the pixmap cache
|
//This function is meant for the pixmap cache
|
||||||
QString SvgPrivate::cachePath(const QString &path, const QSize &size)
|
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)
|
bool SvgPrivate::setImagePath(const QString &imagePath)
|
||||||
@ -280,7 +279,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, const QSizeF &s)
|
|||||||
if (elementsWithSizeHints.isEmpty()) {
|
if (elementsWithSizeHints.isEmpty()) {
|
||||||
// Fetch all size hinted element ids from the theme's rect cache
|
// Fetch all size hinted element ids from the theme's rect cache
|
||||||
// and store them locally.
|
// 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)) {
|
foreach (const QString &key, cacheAndColorsTheme()->listCachedRectKeys(path)) {
|
||||||
if (sizeHintedKeyExpr.exactMatch(key)) {
|
if (sizeHintedKeyExpr.exactMatch(key)) {
|
||||||
@ -417,7 +416,7 @@ void SvgPrivate::createRenderer()
|
|||||||
//qDebug() << "FAIL! **************************";
|
//qDebug() << "FAIL! **************************";
|
||||||
//qDebug() << path << "**";
|
//qDebug() << path << "**";
|
||||||
|
|
||||||
QString styleSheet = cacheAndColorsTheme()->d->svgStyleSheet(styleHints);
|
QString styleSheet = cacheAndColorsTheme()->d->svgStyleSheet(colorGroup);
|
||||||
styleCrc = qChecksum(styleSheet.toUtf8(), styleSheet.size());
|
styleCrc = qChecksum(styleSheet.toUtf8(), styleSheet.size());
|
||||||
|
|
||||||
QHash<QString, SharedSvgRenderer::Ptr>::const_iterator it = s_renderers.constFind(styleCrc + path);
|
QHash<QString, SharedSvgRenderer::Ptr>::const_iterator it = s_renderers.constFind(styleCrc + path);
|
||||||
@ -440,7 +439,7 @@ void SvgPrivate::createRenderer()
|
|||||||
const QString &elementId = i.key();
|
const QString &elementId = i.key();
|
||||||
const QRectF &elementRect = i.value();
|
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);
|
localRectCache.insert(cacheId, elementRect);
|
||||||
cacheAndColorsTheme()->insertIntoRectsCache(path, cacheId, elementRect);
|
cacheAndColorsTheme()->insertIntoRectsCache(path, cacheId, elementRect);
|
||||||
}
|
}
|
||||||
@ -687,20 +686,20 @@ qreal Svg::devicePixelRatio()
|
|||||||
return d->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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->styleHints = hints;
|
d->colorGroup = group;
|
||||||
d->renderer = 0;
|
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)
|
QPixmap Svg::pixmap(const QString &elementID)
|
||||||
|
@ -61,15 +61,15 @@ class PLASMA_EXPORT Svg : public QObject
|
|||||||
Q_PROPERTY(bool multipleImages READ containsMultipleImages WRITE setContainsMultipleImages)
|
Q_PROPERTY(bool multipleImages READ containsMultipleImages WRITE setContainsMultipleImages)
|
||||||
Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged)
|
Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged)
|
||||||
Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache)
|
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:
|
public:
|
||||||
enum StyleHint{
|
enum ColorGroup {
|
||||||
Normal = 0,
|
NormalColorGroup = 0,
|
||||||
Inverted = 1,
|
ButtonColorGroup = 1,
|
||||||
Highlighted = 2
|
ViewColorGroup = 2
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(StyleHints, StyleHint)
|
Q_ENUMS(ColorGroup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an SVG object that implicitly shares and caches rendering.
|
* Constructs an SVG object that implicitly shares and caches rendering.
|
||||||
@ -101,8 +101,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
qreal devicePixelRatio();
|
qreal devicePixelRatio();
|
||||||
|
|
||||||
void setStyleHints(StyleHints hint);
|
void setColorGroup(ColorGroup group);
|
||||||
StyleHints styleHints() const;
|
ColorGroup colorGroup() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pixmap of the SVG represented by this object.
|
* Returns a pixmap of the SVG represented by this object.
|
||||||
@ -410,9 +410,14 @@ Q_SIGNALS:
|
|||||||
void imagePathChanged();
|
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:
|
private:
|
||||||
SvgPrivate *const d;
|
SvgPrivate *const d;
|
||||||
@ -428,7 +433,5 @@ private:
|
|||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Svg::StyleHints)
|
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
#endif // multiple inclusion guard
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user