diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index d5e855c..b0f3ed4 100644 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -49,6 +49,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele @IBOutlet weak var connectAtLaunchMenuItem: NSMenuItem! @IBOutlet weak var ShowNetworkSpeedItem: NSMenuItem! @IBOutlet weak var checkUpdateMenuItem: NSMenuItem! + @IBOutlet weak var checkUpdateAtLaunchMenuItem: NSMenuItem! // MARK: Variables var statusItemView:StatusItemView! @@ -456,24 +457,26 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele } @IBAction func feedback(_ sender: NSMenuItem) { - NSWorkspace.shared().open(URL(string: "https://github.com/qinyuhang/ShadowsocksX-NG/issues")!) + NSWorkspace.shared().open(URL(string: "https://github.com/shadowsocksr/ShadowsocksX-NG/issues")!) } @IBAction func checkForUpdate(_ sender: NSMenuItem) { checkForUpdate(mustShowAlert: true) } + @IBAction func checkUpdatesAtLaunch(_ sender: NSMenuItem) { + let defaults = UserDefaults.standard + defaults.set(!defaults.bool(forKey: "AutoCheckUpdate"), forKey: "AutoCheckUpdate") + checkUpdateAtLaunchMenuItem.state = defaults.bool(forKey: "AutoCheckUpdate") ? 1 : 0 + } + @IBAction func showAbout(_ sender: NSMenuItem) { NSApp.orderFrontStandardAboutPanel(sender); NSApp.activate(ignoringOtherApps: true) } func updateLaunchAtLoginMenu() { - if launchAtLoginController.launchAtLogin { - lanchAtLoginMenuItem.state = 1 - } else { - lanchAtLoginMenuItem.state = 0 - } + lanchAtLoginMenuItem.state = launchAtLoginController.launchAtLogin ? 1 : 0 } // MARK: this function is use to update menu bar @@ -584,17 +587,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele // statusItemView.setIcon(image!) } - if defaults.bool(forKey: "enable_showSpeed") { - ShowNetworkSpeedItem.state = 1 - }else{ - ShowNetworkSpeedItem.state = 0 - } - - if defaults.bool(forKey: "ConnectAtLaunch") { - connectAtLaunchMenuItem.state = 1 - } else { - connectAtLaunchMenuItem.state = 0 - } + ShowNetworkSpeedItem.state = defaults.bool(forKey: "enable_showSpeed") ? 1 : 0 + connectAtLaunchMenuItem.state = defaults.bool(forKey: "ConnectAtLaunch") ? 1 : 0 + checkUpdateAtLaunchMenuItem.state = defaults.bool(forKey: "AutoCheckUpdate") ? 1 : 0 } func updateServersMenu() { diff --git a/ShadowsocksX-NG/Base.lproj/MainMenu.xib b/ShadowsocksX-NG/Base.lproj/MainMenu.xib index 1099b6a..9b699f2 100644 --- a/ShadowsocksX-NG/Base.lproj/MainMenu.xib +++ b/ShadowsocksX-NG/Base.lproj/MainMenu.xib @@ -1,5 +1,5 @@ - + @@ -17,6 +17,7 @@ + @@ -221,6 +222,12 @@ + + + + + + diff --git a/ShadowsocksX-NG/zh-Hans.lproj/MainMenu.strings b/ShadowsocksX-NG/zh-Hans.lproj/MainMenu.strings index b8b1a16..a056cff 100644 --- a/ShadowsocksX-NG/zh-Hans.lproj/MainMenu.strings +++ b/ShadowsocksX-NG/zh-Hans.lproj/MainMenu.strings @@ -102,3 +102,5 @@ "uEp-Gz-cu0.title" = "HTTP代理设置..."; "wyZ-4G-qg9.title" = "检查更新"; + +"3nJ-zQ-Agj.title" = "打开时检查更新";