path: root/src
diff options
authorVolker Hilsheimer <>2019-07-05 15:41:35 +0200
committerVolker Hilsheimer <>2019-07-11 22:50:20 +0200
commitae972a19288ddd47ceac2ee2b7b090c4d12f4731 (patch)
tree3e7bce8090370217a1c27f759e431f2cb8921b03 /src
parent987dde2965f4fba32984041a0f2709127e9edd93 (diff)
macOS: show QSystemTrayIcon message icons in notification popups
The icon provided was ignored, even though NSUserNotification provides the option to specify a contentImage. The message popping up will show that image on the right side of the notification; it will not repace the application icon on the left side. [ChangeLog][Widgets][QSystemTrayIcon] On macOS, show the icon passed into showMessage in the notification popup Change-Id: I8ecda7f893006e74a4f35f37ddc07063ebfe4e83 Fixes: QTBUG-76916 Reviewed-by: Tor Arne Vestbø <>
Diffstat (limited to 'src')
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/ b/src/plugins/platforms/cocoa/
index 4982f5ee05..16543bfb8c 100644
--- a/src/plugins/platforms/cocoa/
+++ b/src/plugins/platforms/cocoa/
@@ -264,7 +264,6 @@ bool QCocoaSystemTrayIcon::supportsMessages() const
void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &message,
const QIcon& icon, MessageIcon, int)
- Q_UNUSED(icon);
if (!m_sys)
@@ -272,6 +271,12 @@ void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &mess
notification.title = [NSString stringWithUTF8String:title.toUtf8().data()];
notification.informativeText = [NSString stringWithUTF8String:message.toUtf8().data()];
+ if (!icon.isNull()) {
+ auto *nsimage = qt_mac_create_nsimage(icon);
+ [nsimage setTemplate:icon.isMask()];
+ notification.contentImage = [nsimage autorelease];
+ }
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];