diff options
| author | Jonas Schnelli <[email protected]> | 2018-12-17 19:53:25 -1000 |
|---|---|---|
| committer | Jonas Schnelli <[email protected]> | 2018-12-17 19:53:51 -1000 |
| commit | e7b88ecbc920321290941bc68e4a71634889c3cb (patch) | |
| tree | 3dcfd0f5f4b1a7a80cca0a992f80ad6dcd157647 /src | |
| parent | Merge #14957: wallet: Initialize stop_block in CWallet::ScanForWalletTransact... (diff) | |
| parent | Refactoring with QString::toNSString (diff) | |
| download | discoin-e7b88ecbc920321290941bc68e4a71634889c3cb.tar.xz discoin-e7b88ecbc920321290941bc68e4a71634889c3cb.zip | |
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.mm | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/src/qt/macnotificationhandler.mm b/src/qt/macnotificationhandler.mm index 0e04d50ba..a07079eec 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]; } } |