diff options
-rw-r--r-- | src/imports/controls/doc/src/includes/qquickicon.qdocinc | 6 | ||||
-rw-r--r-- | src/imports/controls/plugins.qmltypes | 1 | ||||
-rw-r--r-- | src/quickcontrols2/qquickiconlabel.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickicon.cpp | 28 | ||||
-rw-r--r-- | src/quicktemplates2/qquickicon_p.h | 5 |
5 files changed, 41 insertions, 1 deletions
diff --git a/src/imports/controls/doc/src/includes/qquickicon.qdocinc b/src/imports/controls/doc/src/includes/qquickicon.qdocinc index a6ab90bb..ba7cede9 100644 --- a/src/imports/controls/doc/src/includes/qquickicon.qdocinc +++ b/src/imports/controls/doc/src/includes/qquickicon.qdocinc @@ -38,5 +38,11 @@ The icon is tinted with the specified color, unless the color is set to \c "transparent". + +\row + \li cache + \li This property specifies whether the icon should be cached. + + The default value is true. \endtable //! [grouped-properties] diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes index 949eea62..f4d2a30a 100644 --- a/src/imports/controls/plugins.qmltypes +++ b/src/imports/controls/plugins.qmltypes @@ -1280,6 +1280,7 @@ Module { Property { name: "width"; type: "int" } Property { name: "height"; type: "int" } Property { name: "color"; type: "QColor" } + Property { name: "cache"; type: "bool" } } Component { name: "QQuickItemDelegate" diff --git a/src/quickcontrols2/qquickiconlabel.cpp b/src/quickcontrols2/qquickiconlabel.cpp index 37e6060a..b246621b 100644 --- a/src/quickcontrols2/qquickiconlabel.cpp +++ b/src/quickcontrols2/qquickiconlabel.cpp @@ -81,6 +81,7 @@ bool QQuickIconLabelPrivate::createImage() image->setSource(icon.source()); image->setSourceSize(QSize(icon.width(), icon.height())); image->setColor(icon.color()); + image->setCache(icon.cache()); QQmlEngine::setContextForObject(image, qmlContext(q)); if (componentComplete) completeComponent(image); @@ -114,6 +115,7 @@ void QQuickIconLabelPrivate::syncImage() image->setSource(icon.source()); image->setSourceSize(QSize(icon.width(), icon.height())); image->setColor(icon.color()); + image->setCache(icon.cache()); const int valign = alignment & Qt::AlignVertical_Mask; image->setVerticalAlignment(static_cast<QQuickImage::VAlignment>(valign)); const int halign = alignment & Qt::AlignHorizontal_Mask; diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp index 1b8f4797..5a689108 100644 --- a/src/quicktemplates2/qquickicon.cpp +++ b/src/quicktemplates2/qquickicon.cpp @@ -46,6 +46,7 @@ public: int width = 0; int height = 0; QColor color = Qt::transparent; + bool cache = true; enum ResolveProperties { NameResolved = 0x0001, @@ -53,6 +54,7 @@ public: WidthResolved = 0x0004, HeightResolved = 0x0008, ColorResolved = 0x0010, + CacheResolved = 0x0020, AllPropertiesResolved = 0x1ffff }; @@ -86,7 +88,8 @@ bool QQuickIcon::operator==(const QQuickIcon &other) const && d->source == other.d->source && d->width == other.d->width && d->height == other.d->height - && d->color == other.d->color); + && d->color == other.d->color + && d->cache == other.d->cache); } bool QQuickIcon::operator!=(const QQuickIcon &other) const @@ -199,6 +202,26 @@ void QQuickIcon::resetColor() d->resolveMask &= ~QQuickIconPrivate::ColorResolved; } +bool QQuickIcon::cache() const +{ + return d->cache; +} + +void QQuickIcon::setCache(bool cache) +{ + if ((d->resolveMask & QQuickIconPrivate::CacheResolved) && d->cache == cache) + return; + + d->cache = cache; + d->resolveMask |= QQuickIconPrivate::CacheResolved; +} + +void QQuickIcon::resetCache() +{ + d->cache = true; + d->resolveMask &= ~QQuickIconPrivate::CacheResolved; +} + QQuickIcon QQuickIcon::resolve(const QQuickIcon &other) const { QQuickIcon resolved = *this; @@ -218,6 +241,9 @@ QQuickIcon QQuickIcon::resolve(const QQuickIcon &other) const if (!(d->resolveMask & QQuickIconPrivate::ColorResolved)) resolved.setColor(other.color()); + if (!(d->resolveMask & QQuickIconPrivate::CacheResolved)) + resolved.setCache(other.cache()); + return resolved; } diff --git a/src/quicktemplates2/qquickicon_p.h b/src/quicktemplates2/qquickicon_p.h index 2c95bc9d..57cab720 100644 --- a/src/quicktemplates2/qquickicon_p.h +++ b/src/quicktemplates2/qquickicon_p.h @@ -67,6 +67,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickIcon Q_PROPERTY(int width READ width WRITE setWidth RESET resetWidth FINAL) Q_PROPERTY(int height READ height WRITE setHeight RESET resetHeight FINAL) Q_PROPERTY(QColor color READ color WRITE setColor RESET resetColor FINAL) + Q_PROPERTY(bool cache READ cache WRITE setCache RESET resetCache FINAL) public: QQuickIcon(); @@ -99,6 +100,10 @@ public: void setColor(const QColor &color); void resetColor(); + bool cache() const; + void setCache(bool cache); + void resetCache(); + QQuickIcon resolve(const QQuickIcon &other) const; private: |