Browse Source

Merge pull request #7281 from vit9696/notifications2

Fix notification display on macOS
adaptive-webui-19844
sledgehammer999 7 years ago committed by GitHub
parent
commit
4f0d9605fe
  1. 1
      src/gui/macutilities.h
  2. 12
      src/gui/macutilities.mm
  3. 4
      src/gui/mainwindow.cpp

1
src/gui/macutilities.h

@ -35,5 +35,6 @@ @@ -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

12
src/gui/macutilities.mm

@ -69,3 +69,15 @@ void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...)) @@ -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];
}
}

4
src/gui/mainwindow.cpp

@ -1553,7 +1553,9 @@ void MainWindow::showNotificationBaloon(QString title, QString msg) const @@ -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

Loading…
Cancel
Save