8 #include <Cocoa/Cocoa.h>
15 QByteArray utf8 = title.toUtf8();
16 char* cString = (
char *)utf8.constData();
17 NSString *titleMac = [[NSString alloc] initWithUTF8String:cString];
20 cString = (
char *)utf8.constData();
21 NSString *textMac = [[NSString alloc] initWithUTF8String:cString];
24 id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init];
25 [userNotification performSelector:@selector(setTitle:) withObject:titleMac];
26 [userNotification performSelector:@selector(setInformativeText:) withObject:textMac];
28 id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)];
29 [notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification];
33 [userNotification release];
40 QByteArray utf8 = script.toUtf8();
41 char* cString = (
char *)utf8.constData();
42 NSString *scriptApple = [[NSString alloc] initWithUTF8String:cString];
44 NSAppleScript *as = [[NSAppleScript alloc] initWithSource:scriptApple];
45 NSDictionary *err = nil;
46 [as executeAndReturnError:&err];
48 [scriptApple release];
53 Class possibleClass = NSClassFromString(
@"NSUserNotificationCenter");
56 if(possibleClass!=nil) {
bool hasUserNotificationCenterSupport(void)
check if OS can handle UserNotifications
static MacNotificationHandler * instance()
void sendAppleScript(const QString &script)
executes AppleScript
void showNotification(const QString &title, const QString &text)
shows a 10.8+ UserNotification in the UserNotificationCenter
Macintosh-specific notification handler (supports UserNotificationCenter and Growl).