[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:
parent
e143f7d457
commit
a0ab02c052
@ -141,6 +141,8 @@ void IconItem::setSource(const QVariant &source)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disconnect(KIconLoader::global(), &KIconLoader::iconChanged, this, &IconItem::iconLoaderIconChanged);
|
||||||
|
|
||||||
const bool oldValid = isValid();
|
const bool oldValid = isValid();
|
||||||
|
|
||||||
m_source = source;
|
m_source = source;
|
||||||
@ -209,6 +211,10 @@ void IconItem::setSource(const QVariant &source)
|
|||||||
if (m_icon.isNull()) {
|
if (m_icon.isNull()) {
|
||||||
m_icon = QIcon::fromTheme(sourceString);
|
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();
|
m_svgIconName.clear();
|
||||||
delete m_svgIcon;
|
delete m_svgIcon;
|
||||||
m_svgIcon = nullptr;
|
m_svgIcon = nullptr;
|
||||||
@ -543,6 +549,12 @@ void IconItem::animationFinished()
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IconItem::iconLoaderIconChanged(int group)
|
||||||
|
{
|
||||||
|
Q_UNUSED(group);
|
||||||
|
schedulePixmapUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
void IconItem::schedulePixmapUpdate()
|
void IconItem::schedulePixmapUpdate()
|
||||||
{
|
{
|
||||||
polish();
|
polish();
|
||||||
|
@ -192,6 +192,7 @@ private Q_SLOTS:
|
|||||||
void animationFinished();
|
void animationFinished();
|
||||||
void valueChanged(const QVariant &value);
|
void valueChanged(const QVariant &value);
|
||||||
void onEnabledChanged();
|
void onEnabledChanged();
|
||||||
|
void iconLoaderIconChanged(int group);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadPixmap();
|
void loadPixmap();
|
||||||
|
Loading…
Reference in New Issue
Block a user