diff options
author | Mikhail Svetkin <mikhail.svetkin@qt.io> | 2019-01-22 13:55:59 +0100 |
---|---|---|
committer | Mikhail Svetkin <mikhail.svetkin@qt.io> | 2019-01-22 14:17:42 +0000 |
commit | 033564edf5b79e32da63597930e25105a3442f01 (patch) | |
tree | c513b743ae5f2cbcf297c38c94e621c735c21cfb /src/quicktemplates2/qquickicon.cpp | |
parent | 3e5392dab0fbf1827aad23a5e573df7e8a86b601 (diff) |
QQuickIcon: Add support to cache a pixmap
[ChangeLog][Controls] Added cache property to icon.
Change-Id: I9b3410e74ab8962d039939a8e005a2aff8e026cb
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickicon.cpp')
-rw-r--r-- | src/quicktemplates2/qquickicon.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
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; } |