diff --git a/src/gui/macutilities.h b/src/gui/macutilities.h index 01356d77d..b9eda325f 100644 --- a/src/gui/macutilities.h +++ b/src/gui/macutilities.h @@ -35,5 +35,6 @@ QPixmap pixmapForExtension(const QString &ext, const QSize &size); void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...)); +void displayNotification(const QString &title, const QString &message); #endif // MACUTILITIES_H diff --git a/src/gui/macutilities.mm b/src/gui/macutilities.mm index 358eef7a1..2a6b0c6f6 100644 --- a/src/gui/macutilities.mm +++ b/src/gui/macutilities.mm @@ -69,3 +69,15 @@ void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...)) 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]; + } +} diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index b71f80865..cd9faa6bb 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1553,7 +1553,9 @@ void MainWindow::showNotificationBaloon(QString title, QString msg) const reply.waitForFinished(); if (!reply.isError()) return; -#elif (!defined(Q_OS_MAC)) +#elif defined(Q_OS_MAC) + displayNotification(title, msg); +#else if (m_systrayIcon && QSystemTrayIcon::supportsMessages()) m_systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON); #endif