From 3b115e6d901fc9e74c6393ce21415d13e286a9eb Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Thu, 10 Mar 2016 12:58:18 +0100 Subject: [PATCH] [Icon Item] Don't call loadPixmap in setColorGroup Changing the color group of an Svg emits repaintNeeded which will then cause it to schedule a pixmap update anyway. Includes a unittest. REVIEW: 127313 --- autotests/iconitemtest.cpp | 19 +++++++++++++++++++ autotests/iconitemtest.h | 1 + src/declarativeimports/core/iconitem.cpp | 1 - 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/autotests/iconitemtest.cpp b/autotests/iconitemtest.cpp index ae825a970..b7c973750 100644 --- a/autotests/iconitemtest.cpp +++ b/autotests/iconitemtest.cpp @@ -355,5 +355,24 @@ void IconItemTest::qiconFromTheme() QCOMPARE(icon2, item2->property("source").value()); } +void IconItemTest::changeColorGroup() +{ + // Icon from Plasma theme + QQuickItem *item = createIconItem(); + item->setProperty("animated", false); + item->setProperty("source", "zoom-fit-height"); + Plasma::Svg *svg = item->findChild(); + // not using "breeze" theme as that one follows system color scheme + // and that one might not have a complementary group or a broken one + changeTheme(svg->theme(), "breeze-light"); + QSignalSpy spy(svg, SIGNAL(repaintNeeded())); + QVERIFY(spy.isValid()); + QImage img1 = grabImage(item); + item->setProperty("colorGroup", Plasma::Theme::ComplementaryColorGroup); + QTRY_VERIFY(spy.count() == 1); + QImage img2 = grabImage(item); + QVERIFY(img1 != img2); +} + QTEST_MAIN(IconItemTest) diff --git a/autotests/iconitemtest.h b/autotests/iconitemtest.h index c7ba89f98..47eb445e7 100644 --- a/autotests/iconitemtest.h +++ b/autotests/iconitemtest.h @@ -49,6 +49,7 @@ private Q_SLOTS: void loadSvg(); void themeChange(); void qiconFromTheme(); + void changeColorGroup(); private: QQuickItem *createIconItem(); diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp index 6c23a7efb..0d6fd1486 100644 --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -195,7 +195,6 @@ void IconItem::setColorGroup(Plasma::Theme::ColorGroup group) if (m_svgIcon) { m_svgIcon->setColorGroup(group); - loadPixmap(); } emit colorGroupChanged();