IconItem: Schedule pixmap update when window changes

QQuickItem::polish is not called when window changes.

Regression from 344d04e230

REVIEW: 127342
This commit is contained in:
David Rosca 2016-03-12 13:01:07 +01:00
parent 46a1181587
commit fd46322300
3 changed files with 22 additions and 0 deletions

View File

@ -410,5 +410,23 @@ void IconItemTest::animatingEnabledChange()
QVERIFY(img1 != img2); // animation is running
}
void IconItemTest::windowChanged()
{
QQuickItem *item = createIconItem();
item->setProperty("animated", false);
item->setProperty("source", "tst-plasma-framework-test-icon");
QImage img = grabImage(item);
QQuickView newView;
newView.setSource(QUrl::fromLocalFile(QFINDTESTDATA("data/view.qml")));
newView.show();
QTest::qWaitForWindowExposed(&newView);
item->setProperty("visible", false);
item->setParentItem(newView.rootObject());
item->setProperty("visible", true);
QCOMPARE(grabImage(item), img);
}
QTEST_MAIN(IconItemTest)

View File

@ -52,6 +52,7 @@ private Q_SLOTS:
void changeColorGroup();
void animatingActiveChange();
void animatingEnabledChange();
void windowChanged();
private:
QQuickItem *createIconItem();

View File

@ -69,6 +69,9 @@ IconItem::IconItem(QQuickItem *parent)
connect(this, &QQuickItem::enabledChanged,
this, &IconItem::enabledChanged);
connect(this, &QQuickItem::windowChanged,
this, &IconItem::schedulePixmapUpdate);
//initialize implicit size to the Dialog size
setImplicitWidth(KIconLoader::global()->currentSize(KIconLoader::Dialog));
setImplicitHeight(KIconLoader::global()->currentSize(KIconLoader::Dialog));