From c276163d83d31b90f0a9004d4dc307c9d77abe88 Mon Sep 17 00:00:00 2001 From: Hartmnt Date: Sun, 23 Jun 2024 17:25:00 +0000 Subject: [PATCH] FIX(client): Experimental notifications on OSX --- src/mumble/Log_macx.mm | 47 ++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/mumble/Log_macx.mm b/src/mumble/Log_macx.mm index bedad610622..fc9f428f763 100644 --- a/src/mumble/Log_macx.mm +++ b/src/mumble/Log_macx.mm @@ -9,6 +9,7 @@ #include +#include "widgets/TrayIcon.h" #include "Global.h" #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 @@ -72,34 +73,22 @@ static bool growl_available() { #endif // QT_VERSION void Log::postNotification(MsgType mt, const QString &plain) { - QString title = msgName(mt); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 -# if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) - const QOperatingSystemVersion current = QOperatingSystemVersion::current(); - if (current.majorVersion() > 10 || (current.majorVersion() == 10 && current.minorVersion() >= 8)) { -# else - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_MOUNTAINLION) { -# endif - NSUserNotificationCenter *userNotificationCenter = [NSUserNotificationCenter defaultUserNotificationCenter]; - if (userNotificationCenter.delegate == nil) { - // We hand the delegate property a delegate with a retain count of 1. We don't keep - // a reference to the delegate anywhere else, so it's not really a leak. - userNotificationCenter.delegate = [[MUUserNotificationCenterDelegate alloc] init]; - } - NSUserNotification *userNotification = [[[NSUserNotification alloc] init] autorelease]; - userNotification.title = [Log_QString_to_NSString(title) autorelease]; - userNotification.informativeText = [Log_QString_to_NSString(plain) autorelease]; - [userNotificationCenter scheduleNotification:userNotification]; - } else -#endif - { -#if QT_VERSION < 0x050800 - QString qsScript = QString::fromLatin1( - "tell application \"GrowlHelperApp\"\n" - " notify with name \"%1\" title \"%1\" description \"%2\" application name \"Mumble\"\n" - "end tell\n").arg(title).arg(plain); - if (growl_available()) - qt_mac_execute_apple_script(qsScript, nullptr); -#endif + QSystemTrayIcon::MessageIcon msgIcon; + switch (mt) { + case DebugInfo: + case CriticalError: + msgIcon = QSystemTrayIcon::Critical; + break; + case Warning: + msgIcon = QSystemTrayIcon::Warning; + break; + case TextMessage: + case PrivateTextMessage: + msgIcon = QSystemTrayIcon::NoIcon; + break; + default: + msgIcon = QSystemTrayIcon::Information; + break; } + Global::get().trayIcon->showMessage(msgName(mt), plain, msgIcon); }