Load IconItem immediately upon componentComplete()

This makes the IconItem load the icon immediately after component creation and not
wait 150ms there for no reason which prevents eg. flickering in the OSD when it shows up.

REVIEW: 121219
This commit is contained in:
Kai Uwe Broulik 2014-12-15 20:21:06 +01:00
parent f64207f408
commit 6531279771
2 changed files with 25 additions and 4 deletions

View File

@ -84,6 +84,8 @@ void IconItem::setSource(const QVariant &source)
m_source = source;
const bool oldValid = isValid();
if (source.canConvert<QIcon>()) {
m_icon = source.value<QIcon>();
m_imageIcon = QImage();
@ -96,8 +98,8 @@ void IconItem::setSource(const QVariant &source)
delete m_svgIcon;
m_svgIcon = 0;
m_icon = QIcon();
m_loadPixmapTimer.start();
emit validChanged();
loadPixmap();
return;
}
@ -158,8 +160,12 @@ void IconItem::setSource(const QVariant &source)
}
if (width() > 0 && height() > 0) {
if (!oldValid) {
loadPixmap();
} else {
m_loadPixmapTimer.start();
}
}
emit sourceChanged();
emit validChanged();
@ -202,7 +208,9 @@ void IconItem::setActive(bool active)
}
m_active = active;
if (isComponentComplete()) {
m_loadPixmapTimer.start();
}
emit activeChanged();
}
@ -297,6 +305,10 @@ void IconItem::animationFinished()
void IconItem::loadPixmap()
{
if (!isComponentComplete()) {
return;
}
const int size = Units::roundToIconSize(qMin(width(), height()));
//final pixmap to paint
@ -351,7 +363,7 @@ void IconItem::geometryChanged(const QRectF &newGeometry,
m_sizeChanged = true;
update();
if (newGeometry.width() > 0 && newGeometry.height() > 0) {
if (!m_loadPixmapTimer.isActive()) {
if (!m_loadPixmapTimer.isActive() && isComponentComplete()) {
m_loadPixmapTimer.start();
}
}
@ -360,4 +372,10 @@ void IconItem::geometryChanged(const QRectF &newGeometry,
QQuickItem::geometryChanged(newGeometry, oldGeometry);
}
void IconItem::componentComplete()
{
QQuickItem::componentComplete();
loadPixmap();
}
#include "iconitem.moc"

View File

@ -69,6 +69,8 @@ public:
void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry);
void componentComplete() Q_DECL_OVERRIDE;
Q_SIGNALS:
void activeChanged();
void sourceChanged();
@ -107,6 +109,7 @@ private:
//animation on pixmap change
QPropertyAnimation *m_animation;
qreal m_animValue;
};
#endif