paintedWidth/paintedheight for IconItem

export the actual painted icon size of the icon item
REVIEW:126625

Change-Id: Ifa6667fdb9e3f7ee675b2c36628eae2ea5394a35
This commit is contained in:
Marco Martin 2016-01-04 18:17:33 +01:00
parent 3992593f31
commit c532ca8ff7
2 changed files with 21 additions and 0 deletions

View File

@ -246,6 +246,16 @@ bool IconItem::isValid() const
return !m_icon.isNull() || m_svgIcon || !m_pixmapIcon.isNull() || !m_imageIcon.isNull(); return !m_icon.isNull() || m_svgIcon || !m_pixmapIcon.isNull() || !m_imageIcon.isNull();
} }
int IconItem::paintedWidth() const
{
return Units::roundToIconSize(qMin(boundingRect().size().width(), boundingRect().size().height()));
}
int IconItem::paintedHeight() const
{
return Units::roundToIconSize(qMin(boundingRect().size().width(), boundingRect().size().height()));
}
void IconItem::updatePolish() void IconItem::updatePolish()
{ {
QQuickItem::updatePolish(); QQuickItem::updatePolish();
@ -408,6 +418,11 @@ void IconItem::geometryChanged(const QRectF &newGeometry,
} else { } else {
update(); update();
} }
if (Units::roundToIconSize(qMin(oldGeometry.size().width(), oldGeometry.size().height())) !=
Units::roundToIconSize(qMin(newGeometry.size().width(), newGeometry.size().height()))) {
emit paintedSizeChanged();
}
} }
QQuickItem::geometryChanged(newGeometry, oldGeometry); QQuickItem::geometryChanged(newGeometry, oldGeometry);

View File

@ -44,6 +44,8 @@ class IconItem : public QQuickItem
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
Q_PROPERTY(int paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
Q_PROPERTY(int paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
public: public:
@ -64,6 +66,9 @@ public:
bool isValid() const; bool isValid() const;
int paintedWidth() const;
int paintedHeight() const;
void updatePolish() Q_DECL_OVERRIDE; void updatePolish() Q_DECL_OVERRIDE;
QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) Q_DECL_OVERRIDE; QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) Q_DECL_OVERRIDE;
@ -78,6 +83,7 @@ Q_SIGNALS:
void smoothChanged(); void smoothChanged();
void validChanged(); void validChanged();
void colorGroupChanged(); void colorGroupChanged();
void paintedSizeChanged();
private Q_SLOTS: private Q_SLOTS:
void schedulePixmapUpdate(); void schedulePixmapUpdate();