Merge branch 'mart/svg/stylecolors'
This commit is contained in:
commit
e35aee9cea
@ -32,8 +32,6 @@
|
||||
#include <kiconloader.h>
|
||||
#include <kiconeffect.h>
|
||||
|
||||
#include <plasma/svg.h>
|
||||
|
||||
#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<QString>()) {
|
||||
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;
|
||||
|
@ -27,18 +27,16 @@
|
||||
#include <QVariant>
|
||||
#include <QTimer>
|
||||
|
||||
class QPropertyAnimation;
|
||||
#include <plasma/svg.h>
|
||||
|
||||
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;
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -2,3 +2,4 @@ add_subdirectory( oxygen )
|
||||
add_subdirectory( air )
|
||||
add_subdirectory( breeze )
|
||||
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]
|
||||
enabled=true
|
||||
contrast=0.2
|
||||
intensity=0.4
|
||||
saturation=1.7
|
||||
|
@ -106,6 +106,7 @@ public:
|
||||
QSizeF size;
|
||||
QSizeF naturalSize;
|
||||
QChar styleCrc;
|
||||
Svg::ColorGroup colorGroup;
|
||||
unsigned int lastModified;
|
||||
qreal devicePixelRatio;
|
||||
bool multipleImages : 1;
|
||||
|
@ -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,16 +427,32 @@ const QString ThemePrivate::processStyleSheet(const QString &css)
|
||||
return stylesheet;
|
||||
}
|
||||
|
||||
const QString ThemePrivate::svgStyleSheet()
|
||||
const QString ThemePrivate::svgStyleSheet(Plasma::Svg::ColorGroup group)
|
||||
{
|
||||
QString stylesheet = cachedStyleSheets.value(SVGSTYLE);
|
||||
QString stylesheet = cachedSvgStyleSheets.value(group);
|
||||
if (stylesheet.isEmpty()) {
|
||||
QString skel = QStringLiteral(".ColorScheme-%1{color:%2;}");
|
||||
|
||||
switch (group) {
|
||||
case Svg::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:
|
||||
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("Background"), QStringLiteral("%backgroundcolor"));
|
||||
|
||||
stylesheet += skel.arg(QStringLiteral("Highlight"), QStringLiteral("%highlightcolor"));
|
||||
}
|
||||
|
||||
|
||||
stylesheet += skel.arg(QStringLiteral("ButtonText"), QStringLiteral("%buttontextcolor"));
|
||||
stylesheet += skel.arg(QStringLiteral("ButtonBackground"), QStringLiteral("%buttonbackgroundcolor"));
|
||||
@ -449,7 +465,7 @@ const QString ThemePrivate::svgStyleSheet()
|
||||
stylesheet += skel.arg(QStringLiteral("ViewFocus"), QStringLiteral("%viewfocuscolor"));
|
||||
|
||||
stylesheet = processStyleSheet(stylesheet);
|
||||
cachedStyleSheets.insert(SVGSTYLE, stylesheet);
|
||||
cachedSvgStyleSheets.insert(group, stylesheet);
|
||||
}
|
||||
|
||||
return stylesheet;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define PLASMA_THEME_P_H
|
||||
|
||||
#include "theme.h"
|
||||
#include "svg.h"
|
||||
#include <QHash>
|
||||
|
||||
#include <QDebug>
|
||||
@ -49,11 +50,6 @@ class Theme;
|
||||
static const int DEFAULT_WALLPAPER_WIDTH = 1920;
|
||||
static const int DEFAULT_WALLPAPER_HEIGHT = 1200;
|
||||
|
||||
enum styles {
|
||||
DEFAULTSTYLE,
|
||||
SVGSTYLE
|
||||
};
|
||||
|
||||
enum CacheType {
|
||||
NoCache = 0,
|
||||
PixmapCache = 1,
|
||||
@ -82,7 +78,7 @@ public:
|
||||
void processContrastSettings(KConfigBase *metadata);
|
||||
|
||||
const QString processStyleSheet(const QString &css);
|
||||
const QString svgStyleSheet();
|
||||
const QString svgStyleSheet(Plasma::Svg::ColorGroup group);
|
||||
QColor color(Theme::ColorRole role) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
@ -129,11 +125,12 @@ public:
|
||||
int defaultWallpaperHeight;
|
||||
KImageCache *pixmapCache;
|
||||
KSharedConfigPtr svgElementsCache;
|
||||
QString cachedDefaultStyleSheet;
|
||||
QHash<QString, QSet<QString> > invalidElements;
|
||||
QHash<QString, QPixmap> pixmapsToCache;
|
||||
QHash<QString, QString> keysToCache;
|
||||
QHash<QString, QString> idsToCache;
|
||||
QHash<styles, QString> cachedStyleSheets;
|
||||
QHash<Svg::ColorGroup, QString> cachedSvgStyleSheets;
|
||||
QHash<QString, QString> discoveries;
|
||||
QTimer *pixmapSaveTimer;
|
||||
QTimer *rectSaveTimer;
|
||||
|
@ -135,6 +135,7 @@ SvgPrivate::SvgPrivate(Svg *svg)
|
||||
: q(svg),
|
||||
renderer(0),
|
||||
styleCrc(0),
|
||||
colorGroup(Plasma::Svg::NormalColorGroup),
|
||||
lastModified(0),
|
||||
devicePixelRatio(1.0),
|
||||
multipleImages(false),
|
||||
@ -164,7 +165,7 @@ QString SvgPrivate::cacheId(const QString &elementId)
|
||||
//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);
|
||||
return CACHE_ID_WITH_SIZE(size, path, devicePixelRatio) % QLSEP % QString::number(colorGroup);
|
||||
}
|
||||
|
||||
bool SvgPrivate::setImagePath(const QString &imagePath)
|
||||
@ -415,7 +416,7 @@ void SvgPrivate::createRenderer()
|
||||
//qDebug() << "FAIL! **************************";
|
||||
//qDebug() << path << "**";
|
||||
|
||||
QString styleSheet = cacheAndColorsTheme()->d->svgStyleSheet();
|
||||
QString styleSheet = cacheAndColorsTheme()->d->svgStyleSheet(colorGroup);
|
||||
styleCrc = qChecksum(styleSheet.toUtf8(), styleSheet.size());
|
||||
|
||||
QHash<QString, SharedSvgRenderer::Ptr>::const_iterator it = s_renderers.constFind(styleCrc + path);
|
||||
@ -685,6 +686,22 @@ qreal Svg::devicePixelRatio()
|
||||
return d->devicePixelRatio;
|
||||
}
|
||||
|
||||
void Svg::setColorGroup(Svg::ColorGroup group)
|
||||
{
|
||||
if (d->colorGroup == group) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->colorGroup = group;
|
||||
d->renderer = 0;
|
||||
emit colorGroupChanged();
|
||||
}
|
||||
|
||||
Svg::ColorGroup Svg::colorGroup() const
|
||||
{
|
||||
return d->colorGroup;
|
||||
}
|
||||
|
||||
QPixmap Svg::pixmap(const QString &elementID)
|
||||
{
|
||||
if (elementID.isNull() || d->multipleImages) {
|
||||
|
@ -61,8 +61,16 @@ 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);
|
||||
|
||||
public:
|
||||
enum ColorGroup {
|
||||
NormalColorGroup = 0,
|
||||
ButtonColorGroup = 1,
|
||||
ViewColorGroup = 2
|
||||
};
|
||||
Q_ENUMS(ColorGroup)
|
||||
|
||||
/**
|
||||
* Constructs an SVG object that implicitly shares and caches rendering.
|
||||
*
|
||||
@ -93,6 +101,20 @@ public:
|
||||
*/
|
||||
qreal devicePixelRatio();
|
||||
|
||||
/**
|
||||
* Set a color group for the Svg.
|
||||
* if the Svg uses stylesheets and has elements
|
||||
* that are eithe TextColor or BackgroundColor class,
|
||||
* make them use ButtonTextColor/ButtonBackgroundColor
|
||||
* or ViewTextColor/ViewBackgroundColor
|
||||
*/
|
||||
void setColorGroup(ColorGroup group);
|
||||
|
||||
/**
|
||||
* @return the color group for this Svg
|
||||
*/
|
||||
ColorGroup colorGroup() const;
|
||||
|
||||
/**
|
||||
* Returns a pixmap of the SVG represented by this object.
|
||||
*
|
||||
@ -398,6 +420,16 @@ Q_SIGNALS:
|
||||
*/
|
||||
void imagePathChanged();
|
||||
|
||||
/**
|
||||
* Emitted whenever the color hint has changed.
|
||||
*/
|
||||
void colorHintChanged();
|
||||
|
||||
/**
|
||||
* Emitted whenever the color group has changed.
|
||||
*/
|
||||
void colorGroupChanged();
|
||||
|
||||
private:
|
||||
SvgPrivate *const d;
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
Loading…
Reference in New Issue
Block a user