[Icon Item] Block next animation also based on window visibility

Plasma Dialog used to change the item's visiblity but this is no longer the case, so it would animate when a window is shown and
the source has changed in the meantime.

Differential Revision: https://phabricator.kde.org/D19421
This commit is contained in:
Kai Uwe Broulik 2019-02-28 15:58:26 +01:00
parent 6e2ac5f9ce
commit b6a6bb8e17
2 changed files with 19 additions and 0 deletions

View File

@ -556,6 +556,13 @@ void IconItem::iconLoaderIconChanged(int group)
schedulePixmapUpdate();
}
void IconItem::windowVisibleChanged(bool visible)
{
if (visible) {
m_blockNextAnimation = true;
}
}
void IconItem::schedulePixmapUpdate()
{
polish();
@ -670,7 +677,15 @@ void IconItem::itemChange(ItemChange change, const ItemChangeData &value)
} else if (change == ItemEnabledHasChanged) {
onEnabledChanged();
} else if (change == ItemSceneChange && value.window) {
if (m_window) {
disconnect(m_window.data(), &QWindow::visibleChanged, this, &IconItem::windowVisibleChanged);
}
m_window = value.window;
if (m_window) {
connect(m_window.data(), &QWindow::visibleChanged, this, &IconItem::windowVisibleChanged);
}
schedulePixmapUpdate();
}
QQuickItem::itemChange(change, value);

View File

@ -24,6 +24,7 @@
#include <QIcon>
#include <QQuickItem>
#include <QPixmap>
#include <QPointer>
#include <QVariant>
#include <QTimer>
@ -193,6 +194,7 @@ private Q_SLOTS:
void valueChanged(const QVariant &value);
void onEnabledChanged();
void iconLoaderIconChanged(int group);
void windowVisibleChanged(bool visible);
private:
void loadPixmap();
@ -231,6 +233,8 @@ private:
//animation on pixmap change
QPropertyAnimation *m_animation;
qreal m_animValue;
QPointer<QWindow> m_window;
};
#endif