aboutsummaryrefslogtreecommitdiff
path: root/src/qt/macnotificationhandler.mm
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2018-12-16 20:29:56 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2018-12-16 20:29:56 +0200
commit4d454dcb64d6c85ab41be3da763dd4753ef057f3 (patch)
tree22114e04520f1b63c7ac6faa904aacc879eb6739 /src/qt/macnotificationhandler.mm
parent34241716852df6ea6a3543822f3bf6f886519d4b (diff)
downloadbitcoin-4d454dcb64d6c85ab41be3da763dd4753ef057f3.tar.xz
Refactoring with QString::toNSString
The behavior of MacNotificationHandler::showNotification() has not been changed.
Diffstat (limited to 'src/qt/macnotificationhandler.mm')
-rw-r--r--src/qt/macnotificationhandler.mm23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/qt/macnotificationhandler.mm b/src/qt/macnotificationhandler.mm
index 0e04d50baa..a07079eece 100644
--- a/src/qt/macnotificationhandler.mm
+++ b/src/qt/macnotificationhandler.mm
@@ -24,25 +24,10 @@ void MacNotificationHandler::showNotification(const QString &title, const QStrin
{
// check if users OS has support for NSUserNotification
if(this->hasUserNotificationCenterSupport()) {
- // okay, seems like 10.8+
- QByteArray utf8 = title.toUtf8();
- char* cString = (char *)utf8.constData();
- NSString *titleMac = [[NSString alloc] initWithUTF8String:cString];
-
- utf8 = text.toUtf8();
- cString = (char *)utf8.constData();
- NSString *textMac = [[NSString alloc] initWithUTF8String:cString];
-
- // do everything weak linked (because we will keep <10.8 compatibility)
- id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init];
- [userNotification performSelector:@selector(setTitle:) withObject:titleMac];
- [userNotification performSelector:@selector(setInformativeText:) withObject:textMac];
-
- id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)];
- [notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification];
-
- [titleMac release];
- [textMac release];
+ NSUserNotification* userNotification = [[NSUserNotification alloc] init];
+ userNotification.title = title.toNSString();
+ userNotification.informativeText = text.toNSString();
+ [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: userNotification];
[userNotification release];
}
}