4 #include <Cocoa/Cocoa.h>
11 QByteArray utf8 = title.toUtf8();
12 char* cString = (
char *)utf8.constData();
13 NSString *titleMac = [[NSString alloc] initWithUTF8String:cString];
16 cString = (
char *)utf8.constData();
17 NSString *textMac = [[NSString alloc] initWithUTF8String:cString];
20 id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init];
21 [userNotification performSelector:@selector(setTitle:) withObject:titleMac];
22 [userNotification performSelector:@selector(setInformativeText:) withObject:textMac];
24 id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)];
25 [notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification];
29 [userNotification release];
36 QByteArray utf8 = script.toUtf8();
37 char* cString = (
char *)utf8.constData();
38 NSString *scriptApple = [[NSString alloc] initWithUTF8String:cString];
40 NSAppleScript *as = [[NSAppleScript alloc] initWithSource:scriptApple];
41 NSDictionary *err = nil;
42 [as executeAndReturnError:&err];
44 [scriptApple release];
49 Class possibleClass = NSClassFromString(
@"NSUserNotificationCenter");
52 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).