aboutsummaryrefslogtreecommitdiff
path: root/src/qt/notificator.cpp
diff options
context:
space:
mode:
authorJonas Schnelli <jonas.schnelli@include7.ch>2013-05-10 22:20:51 +0200
committerJonas Schnelli <jonas.schnelli@include7.ch>2013-05-24 12:51:46 +0200
commitb4b017059514ed0157877984363ed94f5ab098e9 (patch)
treeb8bd52d5059231402fcd6df591e6169e6571e712 /src/qt/notificator.cpp
parent5b5d399593adbdf8b9b4fb49ef39d51d4eac03cd (diff)
downloadbitcoin-b4b017059514ed0157877984363ed94f5ab098e9.tar.xz
osx: make use of the 10.8+ user notification center to display growl like notifications
- if 10.8, use user notification center, if <10.8, use growl Signed-off-by: Jonas Schnelli <jonas.schnelli@include7.ch>
Diffstat (limited to 'src/qt/notificator.cpp')
-rw-r--r--src/qt/notificator.cpp43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp
index 397e7aa4a0..7cfaef6079 100644
--- a/src/qt/notificator.cpp
+++ b/src/qt/notificator.cpp
@@ -18,7 +18,7 @@
#ifdef Q_OS_MAC
#include <ApplicationServices/ApplicationServices.h>
-extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret);
+#include "macnotificationhandler.h"
#endif
// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128
@@ -47,19 +47,25 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon,
}
#endif
#ifdef Q_OS_MAC
- // Check if Growl is installed (based on Qt's tray icon implementation)
- CFURLRef cfurl;
- OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
- if (status != kLSApplicationNotFoundErr) {
- CFBundleRef bundle = CFBundleCreate(0, cfurl);
- if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
- if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/")))
- mode = Growl13;
- else
- mode = Growl12;
+ // check if users OS has support for NSUserNotification
+ if( MacNotificationHandler::instance()->hasUserNotificationCenterSupport()) {
+ mode = UserNotificationCenter;
+ }
+ else {
+ // Check if Growl is installed (based on Qt's tray icon implementation)
+ CFURLRef cfurl;
+ OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
+ if (status != kLSApplicationNotFoundErr) {
+ CFBundleRef bundle = CFBundleCreate(0, cfurl);
+ if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
+ if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/")))
+ mode = Growl13;
+ else
+ mode = Growl12;
+ }
+ CFRelease(cfurl);
+ CFRelease(bundle);
}
- CFRelease(cfurl);
- CFRelease(bundle);
}
#endif
}
@@ -269,8 +275,14 @@ void Notificator::notifyGrowl(Class cls, const QString &title, const QString &te
quotedTitle.replace("\\", "\\\\").replace("\"", "\\");
quotedText.replace("\\", "\\\\").replace("\"", "\\");
QString growlApp(this->mode == Notificator::Growl13 ? "Growl" : "GrowlHelperApp");
- qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp), 0);
+ MacNotificationHandler::instance()->sendAppleScript(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp));
+}
+
+void Notificator::notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon) {
+ // icon is not supported by the user notification center yet. OSX will use the app icon.
+ MacNotificationHandler::instance()->showNotification(title, text);
}
+
#endif
void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
@@ -286,6 +298,9 @@ void Notificator::notify(Class cls, const QString &title, const QString &text, c
notifySystray(cls, title, text, icon, millisTimeout);
break;
#ifdef Q_OS_MAC
+ case UserNotificationCenter:
+ notifyMacUserNotificationCenter(cls, title, text, icon);
+ break;
case Growl12:
case Growl13:
notifyGrowl(cls, title, text, icon);