1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

Fix notification display on macOS

This commit is contained in:
vit9696 2017-08-15 21:16:37 +03:00
parent f98edcab5c
commit eb8ff91c5d
3 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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];
}
}

View File

@ -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