[Icon Item] Watch KIconLoader icon change when using QIcon

QIcon is rendered through KIconLoader instead of e.g. Plasma::Svg.
This means we need to recreate the pixmap when the icon theme changes.

CCBUG: 397109

Differential Revision: https://phabricator.kde.org/D14990
This commit is contained in:
Kai Uwe Broulik 2018-08-23 11:31:15 +02:00
parent e143f7d457
commit a0ab02c052
2 changed files with 13 additions and 0 deletions

View File

@ -141,6 +141,8 @@ void IconItem::setSource(const QVariant &source)
return;
}
disconnect(KIconLoader::global(), &KIconLoader::iconChanged, this, &IconItem::iconLoaderIconChanged);
const bool oldValid = isValid();
m_source = source;
@ -209,6 +211,10 @@ void IconItem::setSource(const QVariant &source)
if (m_icon.isNull()) {
m_icon = QIcon::fromTheme(sourceString);
}
//since QIcon is rendered by KIconLoader, watch for when its configuration changes now and reload as needed.
connect(KIconLoader::global(), &KIconLoader::iconChanged, this, &IconItem::iconLoaderIconChanged);
m_svgIconName.clear();
delete m_svgIcon;
m_svgIcon = nullptr;
@ -543,6 +549,12 @@ void IconItem::animationFinished()
update();
}
void IconItem::iconLoaderIconChanged(int group)
{
Q_UNUSED(group);
schedulePixmapUpdate();
}
void IconItem::schedulePixmapUpdate()
{
polish();

View File

@ -192,6 +192,7 @@ private Q_SLOTS:
void animationFinished();
void valueChanged(const QVariant &value);
void onEnabledChanged();
void iconLoaderIconChanged(int group);
private:
void loadPixmap();