diff --git a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib index 8142d87..c08dcca 100644 --- a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib +++ b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib @@ -16,6 +16,7 @@ + diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index d15a335..ab0535a 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -26,6 +26,7 @@ class PreferencesWindowController: NSWindowController @IBOutlet weak var copyURLBtn: NSButton! + @IBOutlet weak var removeButton: NSButton! let tableViewDragType: String = "ss.server.profile.data" var defaults: NSUserDefaults! @@ -33,6 +34,7 @@ class PreferencesWindowController: NSWindowController var editingProfile: ServerProfile! + override func windowDidLoad() { super.windowDidLoad() @@ -64,6 +66,7 @@ class PreferencesWindowController: NSWindowController @IBAction func addProfile(sender: NSButton) { if editingProfile != nil && !editingProfile.isValid(){ + shakeWindows() return } profilesTableView.beginUpdates() @@ -131,6 +134,12 @@ class PreferencesWindowController: NSWindowController } func updateProfileBoxVisible() { + if profileMgr.profiles.count == 1 { + removeButton.enabled = false + }else{ + removeButton.enabled = true + } + if profileMgr.profiles.isEmpty { profileBox.hidden = true } else {