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ø <tor.arne.vestbo@qt.io>bb10
parent
987dde2965
commit
ae972a1928
|
|
@ -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)
|
||||
return;
|
||||
|
||||
|
|
@ -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];
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue