9 #include <Cocoa/Cocoa.h>
16 QByteArray utf8 = title.toUtf8();
17 char* cString = (
char *)utf8.constData();
18 NSString *titleMac = [[NSString alloc] initWithUTF8String:cString];
21 cString = (
char *)utf8.constData();
22 NSString *textMac = [[NSString alloc] initWithUTF8String:cString];
25 id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init];
26 [userNotification performSelector:@selector(setTitle:) withObject:titleMac];
27 [userNotification performSelector:@selector(setInformativeText:) withObject:textMac];
29 id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)];
30 [notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification];
34 [userNotification release];
41 QByteArray utf8 = script.toUtf8();
42 char* cString = (
char *)utf8.constData();
43 NSString *scriptApple = [[NSString alloc] initWithUTF8String:cString];
45 NSAppleScript *as = [[NSAppleScript alloc] initWithSource:scriptApple];
46 NSDictionary *err = nil;
47 [as executeAndReturnError:&err];
49 [scriptApple release];
54 Class possibleClass = NSClassFromString(
@"NSUserNotificationCenter");
57 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).