QSystemTrayIcon on macOS: support the timeout hint in showMessage
If set, schedule a call to remove the notification (NSTimeInterval is specified in seconds). The system might hide the notification balloon earlier, but the notification will still be removed from the message center after the specified interval. Task-number: QTBUG-77150 Change-Id: I510e412beb16e9de271290798f3e66310f44df4f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>bb10
parent
c66732b979
commit
64ed4081ca
|
|
@ -65,7 +65,7 @@ public:
|
|||
void updateMenu(QPlatformMenu *menu) override;
|
||||
QRect geometry() const override;
|
||||
void showMessage(const QString &title, const QString &msg,
|
||||
const QIcon& icon, MessageIcon iconType, int secs) override;
|
||||
const QIcon& icon, MessageIcon iconType, int msecs) override;
|
||||
|
||||
bool isSystemTrayAvailable() const override;
|
||||
bool supportsMessages() const override;
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ bool QCocoaSystemTrayIcon::supportsMessages() const
|
|||
}
|
||||
|
||||
void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &message,
|
||||
const QIcon& icon, MessageIcon, int)
|
||||
const QIcon& icon, MessageIcon, int msecs)
|
||||
{
|
||||
if (!m_sys)
|
||||
return;
|
||||
|
|
@ -282,6 +282,10 @@ void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &mess
|
|||
NSUserNotificationCenter *center = NSUserNotificationCenter.defaultUserNotificationCenter;
|
||||
center.delegate = m_sys->item;
|
||||
[center deliverNotification:notification];
|
||||
if (msecs) {
|
||||
NSTimeInterval timeout = msecs / 1000.0;
|
||||
[center performSelector:@selector(removeDeliveredNotification:) withObject:notification afterDelay:timeout];
|
||||
}
|
||||
[notification release];
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue