rename state property in status

emergency change: in Qml the name "state" for a property
is reserved for the internal state machine, so any object that
exposes a "state" property on its own would automatically
break the state machine
This commit is contained in:
Marco Martin 2016-06-01 14:47:56 +02:00
parent 8919e11c6e
commit 4de0dd2e90
10 changed files with 74 additions and 74 deletions

View File

@ -267,7 +267,7 @@ FrameSvgItem::FrameSvgItem(QQuickItem *parent)
connect(m_frameSvg, SIGNAL(repaintNeeded()), this, SLOT(doUpdate())); connect(m_frameSvg, SIGNAL(repaintNeeded()), this, SLOT(doUpdate()));
connect(&m_units, &Units::devicePixelRatioChanged, this, &FrameSvgItem::updateDevicePixelRatio); connect(&m_units, &Units::devicePixelRatioChanged, this, &FrameSvgItem::updateDevicePixelRatio);
connect(m_frameSvg, &Svg::fromCurrentThemeChanged, this, &FrameSvgItem::fromCurrentThemeChanged); connect(m_frameSvg, &Svg::fromCurrentThemeChanged, this, &FrameSvgItem::fromCurrentThemeChanged);
connect(m_frameSvg, &Svg::stateChanged, this, &FrameSvgItem::stateChanged); connect(m_frameSvg, &Svg::statusChanged, this, &FrameSvgItem::statusChanged);
} }
FrameSvgItem::~FrameSvgItem() FrameSvgItem::~FrameSvgItem()
@ -372,14 +372,14 @@ bool FrameSvgItem::fromCurrentTheme() const
return m_frameSvg->fromCurrentTheme(); return m_frameSvg->fromCurrentTheme();
} }
void FrameSvgItem::setState(Plasma::Svg::State state) void FrameSvgItem::setStatus(Plasma::Svg::Status status)
{ {
m_frameSvg->setState(state); m_frameSvg->setStatus(status);
} }
Plasma::Svg::State FrameSvgItem::state() const Plasma::Svg::Status FrameSvgItem::status() const
{ {
return m_frameSvg->state(); return m_frameSvg->status();
} }
void FrameSvgItem::setEnabledBorders(const Plasma::FrameSvg::EnabledBorders borders) void FrameSvgItem::setEnabledBorders(const Plasma::FrameSvg::EnabledBorders borders)

View File

@ -159,15 +159,15 @@ class FrameSvgItem : public QQuickItem
Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged)
/** /**
* Sets the image in a selected state. * Sets the image in a selected status.
* Svgs can be colored with system color themes, if the state is selected, * Svgs can be colored with system color themes, if the status is selected,
* the TextColor will become HighlightedText color and BackgroundColor * the TextColor will become HighlightedText color and BackgroundColor
* will become HighlightColor, making the svg graphics (for instance an icon) * will become HighlightColor, making the svg graphics (for instance an icon)
* will look correct together selected text * will look correct together selected text
* @see Plasma::Svg::state * @see Plasma::Svg::status
* @since 5.23 * @since 5.23
*/ */
Q_PROPERTY(Plasma::Svg::State state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(Plasma::Svg::Status status READ status WRITE setStatus NOTIFY statusChanged)
public: public:
/** /**
@ -198,8 +198,8 @@ public:
bool fromCurrentTheme() const; bool fromCurrentTheme() const;
void setState(Plasma::Svg::State state); void setStatus(Plasma::Svg::Status status);
Plasma::Svg::State state() const; Plasma::Svg::Status status() const;
void geometryChanged(const QRectF &newGeometry, void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry) Q_DECL_OVERRIDE; const QRectF &oldGeometry) Q_DECL_OVERRIDE;
@ -225,7 +225,7 @@ Q_SIGNALS:
void fromCurrentThemeChanged(); void fromCurrentThemeChanged();
void colorGroupChanged(); void colorGroupChanged();
void repaintNeeded(); void repaintNeeded();
void stateChanged(); void statusChanged();
private Q_SLOTS: private Q_SLOTS:
void doUpdate(); void doUpdate();

View File

@ -40,7 +40,7 @@
IconItem::IconItem(QQuickItem *parent) IconItem::IconItem(QQuickItem *parent)
: QQuickItem(parent), : QQuickItem(parent),
m_svgIcon(0), m_svgIcon(0),
m_state(Plasma::Svg::Normal), m_status(Plasma::Svg::Normal),
m_smooth(false), m_smooth(false),
m_active(false), m_active(false),
m_animated(true), m_animated(true),
@ -109,7 +109,7 @@ void IconItem::setSource(const QVariant &source)
if (!m_svgIcon) { if (!m_svgIcon) {
m_svgIcon = new Plasma::Svg(this); m_svgIcon = new Plasma::Svg(this);
m_svgIcon->setColorGroup(m_colorGroup); m_svgIcon->setColorGroup(m_colorGroup);
m_svgIcon->setState(m_state); m_svgIcon->setStatus(m_status);
m_svgIcon->setDevicePixelRatio((window() ? window()->devicePixelRatio() : qApp->devicePixelRatio())); m_svgIcon->setDevicePixelRatio((window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()));
connect(m_svgIcon, &Plasma::Svg::repaintNeeded, this, &IconItem::schedulePixmapUpdate); connect(m_svgIcon, &Plasma::Svg::repaintNeeded, this, &IconItem::schedulePixmapUpdate);
} }
@ -298,22 +298,22 @@ int IconItem::paintedHeight() const
return Units::roundToIconSize(qMin(boundingRect().size().width(), boundingRect().size().height())); return Units::roundToIconSize(qMin(boundingRect().size().width(), boundingRect().size().height()));
} }
void IconItem::setState(Plasma::Svg::State state) void IconItem::setStatus(Plasma::Svg::Status status)
{ {
if (m_state == state) { if (m_status == status) {
return; return;
} }
m_state = state; m_status = status;
if (m_svgIcon) { if (m_svgIcon) {
m_svgIcon->setState(state); m_svgIcon->setStatus(status);
} }
emit stateChanged(); emit statusChanged();
} }
Plasma::Svg::State IconItem::state() const Plasma::Svg::Status IconItem::status() const
{ {
return m_state; return m_status;
} }
void IconItem::updatePolish() void IconItem::updatePolish()

View File

@ -72,15 +72,15 @@ class IconItem : public QQuickItem
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
/** /**
* Sets the image in a selected state. * Sets the image in a selected status.
* Svgs can be colored with system color themes, if the state is selected, * Svgs can be colored with system color themes, if the status is selected,
* the TextColor will become HighlightedText color and BackgroundColor * the TextColor will become HighlightedText color and BackgroundColor
* will become HighlightColor, making the svg graphics (for instance an icon) * will become HighlightColor, making the svg graphics (for instance an icon)
* will look correct together selected text * will look correct together selected text
* @see Plasma::Svg::state * @see Plasma::Svg::status
* @since 5.23 * @since 5.23
*/ */
Q_PROPERTY(Plasma::Svg::State state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(Plasma::Svg::Status status READ status WRITE setStatus NOTIFY statusChanged)
/** /**
* If set, icon will blend when the source is changed * If set, icon will blend when the source is changed
@ -136,8 +136,8 @@ public:
int paintedWidth() const; int paintedWidth() const;
int paintedHeight() const; int paintedHeight() const;
void setState(Plasma::Svg::State state); void setStatus(Plasma::Svg::Status status);
Plasma::Svg::State state() const; Plasma::Svg::Status status() const;
void updatePolish() Q_DECL_OVERRIDE; void updatePolish() Q_DECL_OVERRIDE;
QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) Q_DECL_OVERRIDE; QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) Q_DECL_OVERRIDE;
@ -157,7 +157,7 @@ Q_SIGNALS:
void validChanged(); void validChanged();
void colorGroupChanged(); void colorGroupChanged();
void paintedSizeChanged(); void paintedSizeChanged();
void stateChanged(); void statusChanged();
private Q_SLOTS: private Q_SLOTS:
void schedulePixmapUpdate(); void schedulePixmapUpdate();
@ -176,7 +176,7 @@ private:
QImage m_imageIcon; QImage m_imageIcon;
//this contains the raw variant it was passed //this contains the raw variant it was passed
QVariant m_source; QVariant m_source;
Plasma::Svg::State m_state; Plasma::Svg::Status m_status;
QSizeF m_implicitSize; QSizeF m_implicitSize;

View File

@ -112,7 +112,7 @@ public:
unsigned int lastModified; unsigned int lastModified;
qreal devicePixelRatio; qreal devicePixelRatio;
qreal scaleFactor; qreal scaleFactor;
Svg::State state; Svg::Status status;
bool multipleImages : 1; bool multipleImages : 1;
bool themed : 1; bool themed : 1;
bool useSystemColors : 1; bool useSystemColors : 1;

View File

@ -411,7 +411,7 @@ void ThemePrivate::notifyOfChanged()
emit themeChanged(); emit themeChanged();
} }
const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::State state) const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::Status status)
{ {
QString stylesheet; QString stylesheet;
if (css.isEmpty()) { if (css.isEmpty()) {
@ -428,7 +428,7 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S
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 = cachedDefaultStyleSheet = processStyleSheet(stylesheet, state); stylesheet = cachedDefaultStyleSheet = processStyleSheet(stylesheet, status);
} }
return stylesheet; return stylesheet;
@ -439,8 +439,8 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S
QHash<QString, QString> elements; QHash<QString, QString> elements;
// If you add elements here, make sure their names are sufficiently unique to not cause // If you add elements here, make sure their names are sufficiently unique to not cause
// clashes between element keys // clashes between element keys
elements[QStringLiteral("%textcolor")] = color(state == Svg::State::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%textcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::NormalColorGroup).name();
elements[QStringLiteral("%backgroundcolor")] = color(state == Svg::State::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%backgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::NormalColorGroup).name();
elements[QStringLiteral("%highlightcolor")] = color(Theme::HighlightColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%highlightcolor")] = color(Theme::HighlightColor, Theme::NormalColorGroup).name();
elements[QStringLiteral("%highlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%highlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::NormalColorGroup).name();
elements[QStringLiteral("%visitedlink")] = color(Theme::VisitedLinkColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%visitedlink")] = color(Theme::VisitedLinkColor, Theme::NormalColorGroup).name();
@ -451,8 +451,8 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S
elements[QStringLiteral("%neutraltextcolor")] = color(Theme::NeutralTextColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%neutraltextcolor")] = color(Theme::NeutralTextColor, Theme::NormalColorGroup).name();
elements[QStringLiteral("%negativetextcolor")] = color(Theme::NegativeTextColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%negativetextcolor")] = color(Theme::NegativeTextColor, Theme::NormalColorGroup).name();
elements[QStringLiteral("%buttontextcolor")] = color(state == Svg::State::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttontextcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ButtonColorGroup).name();
elements[QStringLiteral("%buttonbackgroundcolor")] = color(state == Svg::State::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonbackgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ButtonColorGroup).name();
elements[QStringLiteral("%buttonhovercolor")] = color(Theme::HoverColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonhovercolor")] = color(Theme::HoverColor, Theme::ButtonColorGroup).name();
elements[QStringLiteral("%buttonfocuscolor")] = color(Theme::FocusColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonfocuscolor")] = color(Theme::FocusColor, Theme::ButtonColorGroup).name();
elements[QStringLiteral("%buttonhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ButtonColorGroup).name();
@ -460,8 +460,8 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S
elements[QStringLiteral("%buttonneutraltextcolor")] = color(Theme::NeutralTextColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonneutraltextcolor")] = color(Theme::NeutralTextColor, Theme::ButtonColorGroup).name();
elements[QStringLiteral("%buttonnegativetextcolor")] = color(Theme::NegativeTextColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonnegativetextcolor")] = color(Theme::NegativeTextColor, Theme::ButtonColorGroup).name();
elements[QStringLiteral("%viewtextcolor")] = color(state == Svg::State::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewtextcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ViewColorGroup).name();
elements[QStringLiteral("%viewbackgroundcolor")] = color(state == Svg::State::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewbackgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ViewColorGroup).name();
elements[QStringLiteral("%viewhovercolor")] = color(Theme::HoverColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewhovercolor")] = color(Theme::HoverColor, Theme::ViewColorGroup).name();
elements[QStringLiteral("%viewfocuscolor")] = color(Theme::FocusColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewfocuscolor")] = color(Theme::FocusColor, Theme::ViewColorGroup).name();
elements[QStringLiteral("%viewhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ViewColorGroup).name();
@ -469,8 +469,8 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S
elements[QStringLiteral("%viewneutraltextcolor")] = color(Theme::NeutralTextColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewneutraltextcolor")] = color(Theme::NeutralTextColor, Theme::ViewColorGroup).name();
elements[QStringLiteral("%viewnegativetextcolor")] = color(Theme::NegativeTextColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewnegativetextcolor")] = color(Theme::NegativeTextColor, Theme::ViewColorGroup).name();
elements[QStringLiteral("%complementarytextcolor")] = color(state == Svg::State::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementarytextcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ComplementaryColorGroup).name();
elements[QStringLiteral("%complementarybackgroundcolor")] = color(state == Svg::State::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementarybackgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ComplementaryColorGroup).name();
elements[QStringLiteral("%complementaryhovercolor")] = color(Theme::HoverColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementaryhovercolor")] = color(Theme::HoverColor, Theme::ComplementaryColorGroup).name();
elements[QStringLiteral("%complementaryfocuscolor")] = color(Theme::FocusColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementaryfocuscolor")] = color(Theme::FocusColor, Theme::ComplementaryColorGroup).name();
elements[QStringLiteral("%complementaryhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementaryhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ComplementaryColorGroup).name();
@ -491,9 +491,9 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S
return stylesheet; return stylesheet;
} }
const QString ThemePrivate::svgStyleSheet(Plasma::Theme::ColorGroup group, Plasma::Svg::State state) const QString ThemePrivate::svgStyleSheet(Plasma::Theme::ColorGroup group, Plasma::Svg::Status status)
{ {
QString stylesheet = (state == Svg::State::Selected) ? cachedSelectedSvgStyleSheets.value(group) : cachedSvgStyleSheets.value(group); QString stylesheet = (status == Svg::Status::Selected) ? cachedSelectedSvgStyleSheets.value(group) : cachedSvgStyleSheets.value(group);
if (stylesheet.isEmpty()) { if (stylesheet.isEmpty()) {
QString skel = QStringLiteral(".ColorScheme-%1{color:%2;}"); QString skel = QStringLiteral(".ColorScheme-%1{color:%2;}");
@ -566,8 +566,8 @@ const QString ThemePrivate::svgStyleSheet(Plasma::Theme::ColorGroup group, Plasm
stylesheet += skel.arg(QStringLiteral("ComplementaryNeutralText"), QStringLiteral("%complementaryneutraltextcolor")); stylesheet += skel.arg(QStringLiteral("ComplementaryNeutralText"), QStringLiteral("%complementaryneutraltextcolor"));
stylesheet += skel.arg(QStringLiteral("ComplementaryNegativeText"), QStringLiteral("%complementarynegativetextcolor")); stylesheet += skel.arg(QStringLiteral("ComplementaryNegativeText"), QStringLiteral("%complementarynegativetextcolor"));
stylesheet = processStyleSheet(stylesheet, state); stylesheet = processStyleSheet(stylesheet, status);
if (state == Svg::State::Selected) { if (status == Svg::Status::Selected) {
cachedSelectedSvgStyleSheets.insert(group, stylesheet); cachedSelectedSvgStyleSheets.insert(group, stylesheet);
} else { } else {
cachedSvgStyleSheets.insert(group, stylesheet); cachedSvgStyleSheets.insert(group, stylesheet);
@ -854,7 +854,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
} }
if (realTheme && isDefault && writeSettings) { if (realTheme && isDefault && writeSettings) {
// we're the default theme, let's save our state // we're the default theme, let's save our status
KConfigGroup &cg = config(); KConfigGroup &cg = config();
cg.writeEntry("name", themeName); cg.writeEntry("name", themeName);
cg.sync(); cg.sync();

View File

@ -77,8 +77,8 @@ public:
void processWallpaperSettings(KConfigBase *metadata); void processWallpaperSettings(KConfigBase *metadata);
void processContrastSettings(KConfigBase *metadata); void processContrastSettings(KConfigBase *metadata);
const QString processStyleSheet(const QString &css, Plasma::Svg::State state); const QString processStyleSheet(const QString &css, Plasma::Svg::Status status);
const QString svgStyleSheet(Plasma::Theme::ColorGroup group, Plasma::Svg::State state); const QString svgStyleSheet(Plasma::Theme::ColorGroup group, Plasma::Svg::Status status);
QColor color(Theme::ColorRole role, Theme::ColorGroup group = Theme::NormalColorGroup) const; QColor color(Theme::ColorRole role, Theme::ColorGroup group = Theme::NormalColorGroup) const;
public Q_SLOTS: public Q_SLOTS:

View File

@ -136,8 +136,8 @@ bool SharedSvgRenderer::load(
} }
#define QLSEP QLatin1Char('_') #define QLSEP QLatin1Char('_')
#define CACHE_ID_WITH_SIZE(size, id, state, devicePixelRatio) QString::number(int(size.width())) % QLSEP % QString::number(int(size.height())) % QLSEP % id % QLSEP % QString::number(state) % QLSEP % QString::number(int(devicePixelRatio)) #define CACHE_ID_WITH_SIZE(size, id, status, devicePixelRatio) QString::number(int(size.width())) % QLSEP % QString::number(int(size.height())) % QLSEP % id % QLSEP % QString::number(status) % QLSEP % QString::number(int(devicePixelRatio))
#define CACHE_ID_NATURAL_SIZE(id, state, devicePixelRatio) QLatin1String("Natural") % QLSEP % id % QLSEP % QString::number(state) % QLSEP % QString::number(int(devicePixelRatio)) #define CACHE_ID_NATURAL_SIZE(id, status, devicePixelRatio) QLatin1String("Natural") % QLSEP % id % QLSEP % QString::number(status) % QLSEP % QString::number(int(devicePixelRatio))
SvgPrivate::SvgPrivate(Svg *svg) SvgPrivate::SvgPrivate(Svg *svg)
: q(svg), : q(svg),
@ -147,7 +147,7 @@ SvgPrivate::SvgPrivate(Svg *svg)
lastModified(0), lastModified(0),
devicePixelRatio(1.0), devicePixelRatio(1.0),
scaleFactor(1.0), scaleFactor(1.0),
state(Svg::State::Normal), status(Svg::Status::Normal),
multipleImages(false), multipleImages(false),
themed(false), themed(false),
useSystemColors(false), useSystemColors(false),
@ -168,16 +168,16 @@ SvgPrivate::~SvgPrivate()
QString SvgPrivate::cacheId(const QString &elementId) const QString SvgPrivate::cacheId(const QString &elementId) const
{ {
if (size.isValid() && size != naturalSize) { if (size.isValid() && size != naturalSize) {
return CACHE_ID_WITH_SIZE(size, elementId, state, devicePixelRatio); return CACHE_ID_WITH_SIZE(size, elementId, status, devicePixelRatio);
} else { } else {
return CACHE_ID_NATURAL_SIZE(elementId, state, devicePixelRatio); return CACHE_ID_NATURAL_SIZE(elementId, status, 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) const QString SvgPrivate::cachePath(const QString &path, const QSize &size) const
{ {
return CACHE_ID_WITH_SIZE(size, path, state, devicePixelRatio) % QLSEP % QString::number(colorGroup); return CACHE_ID_WITH_SIZE(size, path, status, devicePixelRatio) % QLSEP % QString::number(colorGroup);
} }
bool SvgPrivate::setImagePath(const QString &imagePath) bool SvgPrivate::setImagePath(const QString &imagePath)
@ -309,7 +309,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi
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+)-(.+)", state, ratio)); QRegExp sizeHintedKeyExpr(CACHE_ID_NATURAL_SIZE("(\\d+)-(\\d+)-(.+)", status, ratio));
foreach (const QString &key, cacheAndColorsTheme()->listCachedRectKeys(path)) { foreach (const QString &key, cacheAndColorsTheme()->listCachedRectKeys(path)) {
if (sizeHintedKeyExpr.exactMatch(key)) { if (sizeHintedKeyExpr.exactMatch(key)) {
@ -455,7 +455,7 @@ void SvgPrivate::createRenderer()
//qCDebug(LOG_PLASMA) << "FAIL! **************************"; //qCDebug(LOG_PLASMA) << "FAIL! **************************";
//qCDebug(LOG_PLASMA) << path << "**"; //qCDebug(LOG_PLASMA) << path << "**";
QString styleSheet = cacheAndColorsTheme()->d->svgStyleSheet(colorGroup, state); QString styleSheet = cacheAndColorsTheme()->d->svgStyleSheet(colorGroup, status);
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);
@ -478,7 +478,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, state, devicePixelRatio); const QString cacheId = CACHE_ID_NATURAL_SIZE(elementId, status, devicePixelRatio);
localRectCache.insert(cacheId, elementRect); localRectCache.insert(cacheId, elementRect);
cacheAndColorsTheme()->insertIntoRectsCache(path, cacheId, elementRect); cacheAndColorsTheme()->insertIntoRectsCache(path, cacheId, elementRect);
} }
@ -980,21 +980,21 @@ Theme *Svg::theme() const
return d->actualTheme(); return d->actualTheme();
} }
void Svg::setState(Plasma::Svg::State state) void Svg::setStatus(Plasma::Svg::Status status)
{ {
if (state == d->state) { if (status == d->status) {
return; return;
} }
d->state = state; d->status = status;
d->eraseRenderer(); d->eraseRenderer();
emit stateChanged(state); emit statusChanged(status);
emit repaintNeeded(); emit repaintNeeded();
} }
Svg::State Svg::state() const Svg::Status Svg::status() const
{ {
return d->state; return d->status;
} }
} // Plasma namespace } // Plasma namespace

View File

@ -63,14 +63,14 @@ class PLASMA_EXPORT Svg : public QObject
Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache) Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache)
Q_PROPERTY(bool fromCurrentTheme READ fromCurrentTheme NOTIFY fromCurrentThemeChanged) Q_PROPERTY(bool fromCurrentTheme READ fromCurrentTheme NOTIFY fromCurrentThemeChanged)
Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged)
Q_PROPERTY(Plasma::Svg::State state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(Plasma::Svg::Status status READ status WRITE setStatus NOTIFY statusChanged)
public: public:
enum State { enum Status {
Normal = 0, Normal = 0,
Selected Selected
}; };
Q_ENUMS(State) Q_ENUMS(Status)
/** /**
* Constructs an SVG object that implicitly shares and caches rendering. * Constructs an SVG object that implicitly shares and caches rendering.
@ -439,21 +439,21 @@ public:
Theme *theme() const; Theme *theme() const;
/** /**
* Sets the image in a selected state. * Sets the image in a selected status.
* Svgs can be colored with system color themes, if the state is selected, * Svgs can be colored with system color themes, if the status is selected,
* the TextColor will become HighlightedText color and BackgroundColor * the TextColor will become HighlightedText color and BackgroundColor
* will become HighlightColor, making the svg graphics (for instance an icon) * will become HighlightColor, making the svg graphics (for instance an icon)
* will look correct together selected text * will look correct together selected text
* Supported states as of 5.23 are Normal and Selected * Supported statuss as of 5.23 are Normal and Selected
* @since 5.23 * @since 5.23
*/ */
void setState(Svg::State state); void setStatus(Svg::Status status);
/** /**
* @return the state of the Svg * @return the status of the Svg
* @since 5.23 * @since 5.23
*/ */
Svg::State state() const; Svg::Status status() const;
Q_SIGNALS: Q_SIGNALS:
/** /**
@ -495,10 +495,10 @@ Q_SIGNALS:
void fromCurrentThemeChanged(bool fromCurrentTheme); void fromCurrentThemeChanged(bool fromCurrentTheme);
/** /**
* Emitted when the state changes * Emitted when the status changes
* @since 5.23 * @since 5.23
*/ */
void stateChanged(Plasma::Svg::State state); void statusChanged(Plasma::Svg::Status status);
private: private:
SvgPrivate *const d; SvgPrivate *const d;

View File

@ -196,7 +196,7 @@ QString Theme::backgroundPath(const QString& image) const
QString Theme::styleSheet(const QString &css) const QString Theme::styleSheet(const QString &css) const
{ {
return d->processStyleSheet(css, Svg::State::Normal); return d->processStyleSheet(css, Svg::Status::Normal);
} }
QString Theme::wallpaperPath(const QSize &size) const QString Theme::wallpaperPath(const QSize &size) const