reload icon when usesPlasmaTheme changes

Summary:
when usesPlasmaTheme gets changed, make sure to
invalidate the svg icon if there, to reload the
icon from the proper source, being either from
the plasma theme or the system icon theme.

Test Plan:
cuttlefish now reloads dynamically the proper icons
when the monochrome checkbox is ticked

Reviewers: #plasma, sebas

Reviewed By: #plasma, sebas

Subscribers: plasma-devel, #frameworks

Tags: #plasma, #frameworks

Differential Revision: https://phabricator.kde.org/D5721
This commit is contained in:
Marco Martin 2017-05-05 20:18:19 +02:00
parent 5ff92e33ff
commit 85699c8d2f

View File

@ -176,6 +176,9 @@ void IconItem::setSource(const QVariant &source)
//try as a svg icon from plasma theme
m_svgIcon->setImagePath(QLatin1String("icons/") + sourceString.split('-').first());
m_svgIcon->setContainsMultipleImages(true);
//invalidate the image path to recalculate it later
} else {
m_svgIcon->setImagePath(QString());
}
//success?
@ -348,12 +351,11 @@ void IconItem::setUsesPlasmaTheme(bool usesPlasmaTheme)
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);
}
const QVariant src = m_source;
m_source.clear();
setSource(src);
update();
emit usesPlasmaThemeChanged();
}