mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Merge pull request #7281 from vit9696/notifications2
Fix notification display on macOS
This commit is contained in:
commit
4f0d9605fe
@ -35,5 +35,6 @@
|
|||||||
|
|
||||||
QPixmap pixmapForExtension(const QString &ext, const QSize &size);
|
QPixmap pixmapForExtension(const QString &ext, const QSize &size);
|
||||||
void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...));
|
void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...));
|
||||||
|
void displayNotification(const QString &title, const QString &message);
|
||||||
|
|
||||||
#endif // MACUTILITIES_H
|
#endif // MACUTILITIES_H
|
||||||
|
@ -69,3 +69,15 @@ void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...))
|
|||||||
qWarning("Failed to register dock click handler");
|
qWarning("Failed to register dock click handler");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void displayNotification(const QString &title, const QString &message)
|
||||||
|
{
|
||||||
|
@autoreleasepool {
|
||||||
|
NSUserNotification *notification = [[NSUserNotification alloc] init];
|
||||||
|
notification.title = title.toNSString();
|
||||||
|
notification.informativeText = message.toNSString();
|
||||||
|
notification.soundName = NSUserNotificationDefaultSoundName;
|
||||||
|
|
||||||
|
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1553,7 +1553,9 @@ void MainWindow::showNotificationBaloon(QString title, QString msg) const
|
|||||||
reply.waitForFinished();
|
reply.waitForFinished();
|
||||||
if (!reply.isError())
|
if (!reply.isError())
|
||||||
return;
|
return;
|
||||||
#elif (!defined(Q_OS_MAC))
|
#elif defined(Q_OS_MAC)
|
||||||
|
displayNotification(title, msg);
|
||||||
|
#else
|
||||||
if (m_systrayIcon && QSystemTrayIcon::supportsMessages())
|
if (m_systrayIcon && QSystemTrayIcon::supportsMessages())
|
||||||
m_systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
|
m_systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user