[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
This commit is contained in:
Kai Uwe Broulik 2016-03-10 12:58:18 +01:00
parent 3decfdd869
commit 3b115e6d90
3 changed files with 20 additions and 1 deletions

View File

@ -355,5 +355,24 @@ void IconItemTest::qiconFromTheme()
QCOMPARE(icon2, item2->property("source").value<QIcon>());
}
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<Plasma::Svg*>();
// 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)

View File

@ -49,6 +49,7 @@ private Q_SLOTS:
void loadSvg();
void themeChange();
void qiconFromTheme();
void changeColorGroup();
private:
QQuickItem *createIconItem();

View File

@ -195,7 +195,6 @@ void IconItem::setColorGroup(Plasma::Theme::ColorGroup group)
if (m_svgIcon) {
m_svgIcon->setColorGroup(group);
loadPixmap();
}
emit colorGroupChanged();