[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
This commit is contained in:
Kai Uwe Broulik 2016-03-10 13:01:29 +01:00
parent 3b115e6d90
commit 344d04e230
3 changed files with 11 additions and 2 deletions

View File

@ -240,8 +240,6 @@ void IconItemTest::animation()
void IconItemTest::animationAfterHide() void IconItemTest::animationAfterHide()
{ {
QEXPECT_FAIL("", "Needs 'no animation after hide' patch", Abort);
QQuickItem *item1 = createIconItem(); QQuickItem *item1 = createIconItem();
QQuickItem *item2 = createIconItem(); QQuickItem *item2 = createIconItem();
item1->setProperty("source", "user-away"); item1->setProperty("source", "user-away");

View File

@ -441,6 +441,16 @@ void IconItem::loadPixmap()
update(); 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, void IconItem::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry) const QRectF &oldGeometry)
{ {

View File

@ -129,6 +129,7 @@ public:
void updatePolish() Q_DECL_OVERRIDE; void updatePolish() Q_DECL_OVERRIDE;
QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) 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, void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry) Q_DECL_OVERRIDE; const QRectF &oldGeometry) Q_DECL_OVERRIDE;