aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2018-12-17 19:53:25 -1000
committerJonas Schnelli <dev@jonasschnelli.ch>2018-12-17 19:53:51 -1000
commite7b88ecbc920321290941bc68e4a71634889c3cb (patch)
tree3dcfd0f5f4b1a7a80cca0a992f80ad6dcd157647 /src
parent27f5a295d7409c1811f74339d509ea7a348a2220 (diff)
parent4d454dcb64d6c85ab41be3da763dd4753ef057f3 (diff)
downloadbitcoin-e7b88ecbc920321290941bc68e4a71634889c3cb.tar.xz
Merge #14975: qt: Refactoring with QString::toNSString()
4d454dcb6 Refactoring with QString::toNSString (Hennadii Stepanov) Pull request description: This PR makes `MacNotificationHandler::showNotification()` cleaner and more readable. The used `QString::toNSString()` function was introduced in Qt 5.2 which is minimum version now (#14725). The behavior of `MacNotificationHandler::showNotification()` has not been changed. cc: @jonasschnelli Tree-SHA512: 940327a77746ee016415efd3b696ad8ec85dcf12bf3f62e55c9bdc1700415d81a8d03fbc79310982d37a4098786dcaef7cd9702db5498d59d8065447babc27f5
Diffstat (limited to 'src')
-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];
}
}