From 63afe0a32539ce52aa5a80e3c84fa918773954ff Mon Sep 17 00:00:00 2001 From: Qiu Yuzhou Date: Tue, 21 Mar 2017 00:11:50 +0800 Subject: [PATCH] In some situation, use toast instead of system user notifications. --- ShadowsocksX-NG/AppDelegate.swift | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index 6899dc5..2302893 100755 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -262,12 +262,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele } else { errMsg = "No current server profile.".localized } - let userNote = NSUserNotification() - userNote.title = errMsg - userNote.soundName = NSUserNotificationDefaultSoundName - - NSUserNotificationCenter.default - .deliver(userNote); + if let msg = errMsg { + self.makeToast(msg) + } } @IBAction func scanQRCodeFromScreen(_ sender: NSMenuItem) { @@ -358,11 +355,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele NSPasteboard.general().clearContents() NSPasteboard.general().setString(command, forType: NSStringPboardType) - // Give a system notification. - let notification = NSUserNotification() - notification.title = "Export Command Copied.".localized - NSUserNotificationCenter.default - .deliver(notification) + // Show a toast notification. + self.makeToast("Export Command Copied.".localized) } @IBAction func showLogs(_ sender: NSMenuItem) {