IconItem: Add usesPlasmaTheme property
Add usesPlasmaTheme (enabled by default) property to make it possible to disable using icons from Plasma theme. REVIEW: 126814
This commit is contained in:
parent
fd9b5bd006
commit
83cec13edb
@ -43,6 +43,7 @@ IconItem::IconItem(QQuickItem *parent)
|
||||
m_smooth(false),
|
||||
m_active(false),
|
||||
m_animated(true),
|
||||
m_usesPlasmaTheme(true),
|
||||
m_textureChanged(false),
|
||||
m_sizeChanged(false),
|
||||
m_svgFromIconLoader(false),
|
||||
@ -115,10 +116,12 @@ void IconItem::setSource(const QVariant &source)
|
||||
m_svgIcon->setColorGroup(m_colorGroup);
|
||||
m_svgIcon->setDevicePixelRatio((window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()));
|
||||
}
|
||||
//try as a svg icon
|
||||
m_svgIcon->setImagePath(QLatin1String("icons/") + sourceString.split('-').first());
|
||||
|
||||
m_svgIcon->setContainsMultipleImages(true);
|
||||
if (m_usesPlasmaTheme) {
|
||||
//try as a svg icon from plasma theme
|
||||
m_svgIcon->setImagePath(QLatin1String("icons/") + sourceString.split('-').first());
|
||||
m_svgIcon->setContainsMultipleImages(true);
|
||||
}
|
||||
|
||||
//success?
|
||||
if (m_svgIcon->isValid() && m_svgIcon->hasElement(sourceString)) {
|
||||
@ -263,6 +266,29 @@ void IconItem::setAnimated(bool animated)
|
||||
emit animatedChanged();
|
||||
}
|
||||
|
||||
bool IconItem::usesPlasmaTheme() const
|
||||
{
|
||||
return m_usesPlasmaTheme;
|
||||
}
|
||||
|
||||
void IconItem::setUsesPlasmaTheme(bool usesPlasmaTheme)
|
||||
{
|
||||
if (m_usesPlasmaTheme == usesPlasmaTheme) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_usesPlasmaTheme = usesPlasmaTheme;
|
||||
|
||||
// Reload icon with new settings
|
||||
if (m_svgIcon && m_svgIcon->hasElement(m_source.toString())) {
|
||||
const QVariant src = m_source;
|
||||
m_source.clear();
|
||||
setSource(src);
|
||||
}
|
||||
|
||||
emit usesPlasmaThemeChanged();
|
||||
}
|
||||
|
||||
bool IconItem::isValid() const
|
||||
{
|
||||
return !m_icon.isNull() || m_svgIcon || !m_pixmapIcon.isNull() || !m_imageIcon.isNull();
|
||||
|
@ -44,6 +44,7 @@ class IconItem : public QQuickItem
|
||||
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
|
||||
Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated NOTIFY animatedChanged)
|
||||
Q_PROPERTY(bool usesPlasmaTheme READ usesPlasmaTheme WRITE setUsesPlasmaTheme NOTIFY usesPlasmaThemeChanged)
|
||||
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
|
||||
Q_PROPERTY(int paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
|
||||
Q_PROPERTY(int paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
|
||||
@ -68,6 +69,9 @@ public:
|
||||
bool isAnimated() const;
|
||||
void setAnimated(bool animated);
|
||||
|
||||
bool usesPlasmaTheme() const;
|
||||
void setUsesPlasmaTheme(bool usesPlasmaTheme);
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
int paintedWidth() const;
|
||||
@ -86,6 +90,7 @@ Q_SIGNALS:
|
||||
void sourceChanged();
|
||||
void smoothChanged();
|
||||
void animatedChanged();
|
||||
void usesPlasmaThemeChanged();
|
||||
void validChanged();
|
||||
void colorGroupChanged();
|
||||
void paintedSizeChanged();
|
||||
@ -111,6 +116,7 @@ private:
|
||||
bool m_smooth;
|
||||
bool m_active;
|
||||
bool m_animated;
|
||||
bool m_usesPlasmaTheme;
|
||||
|
||||
bool m_textureChanged;
|
||||
bool m_sizeChanged;
|
||||
|
Loading…
Reference in New Issue
Block a user