Skip to content

Commit 4d454dc

Browse files
committed
Refactoring with QString::toNSString
The behavior of MacNotificationHandler::showNotification() has not been changed.
1 parent 3424171 commit 4d454dc

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

src/qt/macnotificationhandler.mm

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,10 @@ - (NSString *)__bundleIdentifier
2424
{
2525
// check if users OS has support for NSUserNotification
2626
if(this->hasUserNotificationCenterSupport()) {
27-
// okay, seems like 10.8+
28-
QByteArray utf8 = title.toUtf8();
29-
char* cString = (char *)utf8.constData();
30-
NSString *titleMac = [[NSString alloc] initWithUTF8String:cString];
31-
32-
utf8 = text.toUtf8();
33-
cString = (char *)utf8.constData();
34-
NSString *textMac = [[NSString alloc] initWithUTF8String:cString];
35-
36-
// do everything weak linked (because we will keep <10.8 compatibility)
37-
id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init];
38-
[userNotification performSelector:@selector(setTitle:) withObject:titleMac];
39-
[userNotification performSelector:@selector(setInformativeText:) withObject:textMac];
40-
41-
id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)];
42-
[notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification];
43-
44-
[titleMac release];
45-
[textMac release];
27+
NSUserNotification* userNotification = [[NSUserNotification alloc] init];
28+
userNotification.title = title.toNSString();
29+
userNotification.informativeText = text.toNSString();
30+
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: userNotification];
4631
[userNotification release];
4732
}
4833
}

0 commit comments

Comments
 (0)