From 344d04e2306ca2fdaf17269bc218f4fad065cbbf Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Thu, 10 Mar 2016 13:01:29 +0100 Subject: [PATCH] [Icon Item] Don't animate from previous pixmap when it has been invisible We have a lot of reusable singletons that are just hidden when not needed, such as the OSD. IconItem, however, will always fade from the previous state, even if the previous action happened minutes ago. This fixes for example changing the volume and then later changing the brightness where you could see the OSD animating from the volume icon. REVIEW: 122859 --- autotests/iconitemtest.cpp | 2 -- src/declarativeimports/core/iconitem.cpp | 10 ++++++++++ src/declarativeimports/core/iconitem.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/autotests/iconitemtest.cpp b/autotests/iconitemtest.cpp index b7c973750..3bd114c10 100644 --- a/autotests/iconitemtest.cpp +++ b/autotests/iconitemtest.cpp @@ -240,8 +240,6 @@ void IconItemTest::animation() void IconItemTest::animationAfterHide() { - QEXPECT_FAIL("", "Needs 'no animation after hide' patch", Abort); - QQuickItem *item1 = createIconItem(); QQuickItem *item2 = createIconItem(); item1->setProperty("source", "user-away"); diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp index 0d6fd1486..5798234d0 100644 --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -441,6 +441,16 @@ void IconItem::loadPixmap() update(); } +void IconItem::itemChange(ItemChange change, const ItemChangeData &value) +{ + if (change == ItemVisibleHasChanged && value.boolValue) { + // Clear pixmap to disable animation + m_iconPixmap = QPixmap(); + } + + QQuickItem::itemChange(change, value); +} + void IconItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { diff --git a/src/declarativeimports/core/iconitem.h b/src/declarativeimports/core/iconitem.h index 96133549f..558994a7f 100644 --- a/src/declarativeimports/core/iconitem.h +++ b/src/declarativeimports/core/iconitem.h @@ -129,6 +129,7 @@ public: void updatePolish() Q_DECL_OVERRIDE; QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;