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:
parent
f64207f408
commit
6531279771
@ -84,6 +84,8 @@ void IconItem::setSource(const QVariant &source)
|
|||||||
|
|
||||||
m_source = source;
|
m_source = source;
|
||||||
|
|
||||||
|
const bool oldValid = isValid();
|
||||||
|
|
||||||
if (source.canConvert<QIcon>()) {
|
if (source.canConvert<QIcon>()) {
|
||||||
m_icon = source.value<QIcon>();
|
m_icon = source.value<QIcon>();
|
||||||
m_imageIcon = QImage();
|
m_imageIcon = QImage();
|
||||||
@ -96,8 +98,8 @@ void IconItem::setSource(const QVariant &source)
|
|||||||
delete m_svgIcon;
|
delete m_svgIcon;
|
||||||
m_svgIcon = 0;
|
m_svgIcon = 0;
|
||||||
m_icon = QIcon();
|
m_icon = QIcon();
|
||||||
m_loadPixmapTimer.start();
|
|
||||||
emit validChanged();
|
emit validChanged();
|
||||||
|
loadPixmap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +160,11 @@ void IconItem::setSource(const QVariant &source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (width() > 0 && height() > 0) {
|
if (width() > 0 && height() > 0) {
|
||||||
m_loadPixmapTimer.start();
|
if (!oldValid) {
|
||||||
|
loadPixmap();
|
||||||
|
} else {
|
||||||
|
m_loadPixmapTimer.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit sourceChanged();
|
emit sourceChanged();
|
||||||
@ -202,7 +208,9 @@ void IconItem::setActive(bool active)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_active = active;
|
m_active = active;
|
||||||
m_loadPixmapTimer.start();
|
if (isComponentComplete()) {
|
||||||
|
m_loadPixmapTimer.start();
|
||||||
|
}
|
||||||
emit activeChanged();
|
emit activeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,6 +305,10 @@ void IconItem::animationFinished()
|
|||||||
|
|
||||||
void IconItem::loadPixmap()
|
void IconItem::loadPixmap()
|
||||||
{
|
{
|
||||||
|
if (!isComponentComplete()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const int size = Units::roundToIconSize(qMin(width(), height()));
|
const int size = Units::roundToIconSize(qMin(width(), height()));
|
||||||
|
|
||||||
//final pixmap to paint
|
//final pixmap to paint
|
||||||
@ -351,7 +363,7 @@ void IconItem::geometryChanged(const QRectF &newGeometry,
|
|||||||
m_sizeChanged = true;
|
m_sizeChanged = true;
|
||||||
update();
|
update();
|
||||||
if (newGeometry.width() > 0 && newGeometry.height() > 0) {
|
if (newGeometry.width() > 0 && newGeometry.height() > 0) {
|
||||||
if (!m_loadPixmapTimer.isActive()) {
|
if (!m_loadPixmapTimer.isActive() && isComponentComplete()) {
|
||||||
m_loadPixmapTimer.start();
|
m_loadPixmapTimer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,4 +372,10 @@ void IconItem::geometryChanged(const QRectF &newGeometry,
|
|||||||
QQuickItem::geometryChanged(newGeometry, oldGeometry);
|
QQuickItem::geometryChanged(newGeometry, oldGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IconItem::componentComplete()
|
||||||
|
{
|
||||||
|
QQuickItem::componentComplete();
|
||||||
|
loadPixmap();
|
||||||
|
}
|
||||||
|
|
||||||
#include "iconitem.moc"
|
#include "iconitem.moc"
|
||||||
|
@ -69,6 +69,8 @@ public:
|
|||||||
void geometryChanged(const QRectF &newGeometry,
|
void geometryChanged(const QRectF &newGeometry,
|
||||||
const QRectF &oldGeometry);
|
const QRectF &oldGeometry);
|
||||||
|
|
||||||
|
void componentComplete() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void activeChanged();
|
void activeChanged();
|
||||||
void sourceChanged();
|
void sourceChanged();
|
||||||
@ -107,6 +109,7 @@ private:
|
|||||||
//animation on pixmap change
|
//animation on pixmap change
|
||||||
QPropertyAnimation *m_animation;
|
QPropertyAnimation *m_animation;
|
||||||
qreal m_animValue;
|
qreal m_animValue;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user