From c532ca8ff74cd99d818024611937794d13daa8ef Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 4 Jan 2016 18:17:33 +0100 Subject: [PATCH] paintedWidth/paintedheight for IconItem export the actual painted icon size of the icon item REVIEW:126625 Change-Id: Ifa6667fdb9e3f7ee675b2c36628eae2ea5394a35 --- src/declarativeimports/core/iconitem.cpp | 15 +++++++++++++++ src/declarativeimports/core/iconitem.h | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp index 5a1835477..db15d0fdd 100644 --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -246,6 +246,16 @@ bool IconItem::isValid() const 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() { QQuickItem::updatePolish(); @@ -408,6 +418,11 @@ void IconItem::geometryChanged(const QRectF &newGeometry, } else { 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); diff --git a/src/declarativeimports/core/iconitem.h b/src/declarativeimports/core/iconitem.h index 528f57c17..366edf38b 100644 --- a/src/declarativeimports/core/iconitem.h +++ b/src/declarativeimports/core/iconitem.h @@ -44,6 +44,8 @@ class IconItem : public QQuickItem Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) 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: @@ -64,6 +66,9 @@ public: bool isValid() const; + int paintedWidth() const; + int paintedHeight() const; + void updatePolish() Q_DECL_OVERRIDE; QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) Q_DECL_OVERRIDE; @@ -78,6 +83,7 @@ Q_SIGNALS: void smoothChanged(); void validChanged(); void colorGroupChanged(); + void paintedSizeChanged(); private Q_SLOTS: void schedulePixmapUpdate();