diff options
author | James Turner <james.turner@kdab.com> | 2015-06-24 10:17:04 +0100 |
---|---|---|
committer | James Turner <james.turner@kdab.com> | 2015-07-09 10:53:17 +0000 |
commit | 130c2baa9376dcf525916620294bd9996bdf41f3 (patch) | |
tree | 8933d343ad45d17400aafd1d6533a94a6594e1d0 /src/gui/image | |
parent | bd4ff0b552d5c31eaf35d67208d003b132a4ffba (diff) |
Add ability for QIcons to be marked as template images.
This allows end users to create QSystemTrayIcons that are properly
displayed as monochrome images on OS X, which is especially important
on Yosemite and above when Dark Mode is turned on.
[ChangeLog][QtGui][QIcon] Add ability for QIcons to be marked
as template images. This allows end users to create QSystemTrayIcons
that are properly displayed as monochrome images on OS X, which is
especially important on Yosemite and above when Dark Mode is turned on.
Task-number: QTBUG-42109
Change-Id: I095fb71355ffa572d0abb4769341f68b89b877c4
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 28 | ||||
-rw-r--r-- | src/gui/image/qicon.h | 3 | ||||
-rw-r--r-- | src/gui/image/qicon_p.h | 1 |
3 files changed, 31 insertions, 1 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 60b5b6abd0..40b33b5359 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -129,7 +129,8 @@ static qreal qt_effective_device_pixel_ratio(QWindow *window = 0) QIconPrivate::QIconPrivate() : engine(0), ref(1), serialNum(serialNumCounter.fetchAndAddRelaxed(1)), - detach_no(0) + detach_no(0), + is_mask(false) { } @@ -1196,6 +1197,31 @@ bool QIcon::hasThemeIcon(const QString &name) return icon.name() == name; } +/*! + \since 5.6 + + Indicate that this icon is a mask image, and hence can potentially + be modified based on where it's displayed. + \sa isMask() +*/ +void QIcon::setIsMask(bool isMask) +{ + d->is_mask = isMask; +} + +/*! + \since 5.6 + + Returns \c true if this icon has been marked as a mask image. + Certain platforms render mask icons differently (for example, + menu icons on OS X). + + \sa setIsMask() +*/ +bool QIcon::isMask() const +{ + return d->is_mask; +} /***************************************************************************** QIcon stream functions diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index c33a1f2698..ccddf69101 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -102,6 +102,9 @@ public: QList<QSize> availableSizes(Mode mode = Normal, State state = Off) const; + void setIsMask(bool isMask); + bool isMask() const; + static QIcon fromTheme(const QString &name, const QIcon &fallback = QIcon()); static bool hasThemeIcon(const QString &name); diff --git a/src/gui/image/qicon_p.h b/src/gui/image/qicon_p.h index 8b42e770fa..2a4f584a0d 100644 --- a/src/gui/image/qicon_p.h +++ b/src/gui/image/qicon_p.h @@ -71,6 +71,7 @@ public: QAtomicInt ref; int serialNum; int detach_no; + bool is_mask; }; |