diff --git a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib
index d7a3032..f03790f 100644
--- a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib
+++ b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib
@@ -18,6 +18,7 @@
+
@@ -108,9 +109,9 @@
-
+
-
+
@@ -118,23 +119,6 @@
-
-
-
-
-
-
-
-
-
-
- NSAllRomanInputSourcesLocaleIdentifier
-
-
-
-
-
-
@@ -187,8 +171,8 @@
-
-
+
+
@@ -214,8 +198,11 @@
+
+
+
-
+
@@ -223,7 +210,7 @@
-
+
@@ -231,7 +218,7 @@
-
+
@@ -242,7 +229,7 @@
-
+
@@ -250,33 +237,30 @@
-
-
+
+
-
-
+
+
-
-
-
-
+
@@ -284,7 +268,7 @@
-
+
@@ -292,15 +276,21 @@
-
-
+
+
+
+
+
-
+
+
+
+
@@ -311,9 +301,9 @@
-
+
-
+
@@ -325,7 +315,7 @@
-
+
@@ -335,84 +325,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ NSAllRomanInputSourcesLocaleIdentifier
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+ NSAllRomanInputSourcesLocaleIdentifier
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
-
-
-
-
+
-
+
-
-
+
+
+
-
+
+
-
diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift
index 2bcff8d..4a6d936 100644
--- a/ShadowsocksX-NG/PreferencesWindowController.swift
+++ b/ShadowsocksX-NG/PreferencesWindowController.swift
@@ -7,6 +7,8 @@
//
import Cocoa
+import RxCocoa
+import RxSwift
class PreferencesWindowController: NSWindowController
, NSTableViewDataSource, NSTableViewDelegate {
@@ -18,6 +20,7 @@ class PreferencesWindowController: NSWindowController
@IBOutlet weak var hostTextField: NSTextField!
@IBOutlet weak var portTextField: NSTextField!
+ @IBOutlet weak var kcptunPortTextField: NSTextField!
@IBOutlet weak var methodTextField: NSComboBox!
@IBOutlet weak var passwordTextField: NSTextField!
@@ -41,12 +44,15 @@ class PreferencesWindowController: NSWindowController
var profileMgr: ServerProfileManager!
var editingProfile: ServerProfile!
+
+ var enabledKcptunSubDisosable: Disposable?
override func windowDidLoad() {
super.windowDidLoad()
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
+
defaults = UserDefaults.standard
profileMgr = ServerProfileManager.instance
@@ -202,9 +208,21 @@ class PreferencesWindowController: NSWindowController
func bindProfile(_ index:Int) {
NSLog("bind profile \(index)")
+ if let dis = enabledKcptunSubDisosable {
+ dis.dispose()
+ enabledKcptunSubDisosable = Optional.none
+ }
if index >= 0 && index < profileMgr.profiles.count {
editingProfile = profileMgr.profiles[index]
+
+ enabledKcptunSubDisosable = editingProfile.rx.observeWeakly(Bool.self, "enabledKcptun")
+ .subscribe(onNext: { v in
+ if let enabled = v {
+ self.portTextField.isEnabled = !enabled
+ }
+ })
+
hostTextField.bind("value", to: editingProfile, withKeyPath: "serverHost"
, options: [NSContinuouslyUpdatesValueBindingOption: true])
portTextField.bind("value", to: editingProfile, withKeyPath: "serverPort"
@@ -226,6 +244,9 @@ class PreferencesWindowController: NSWindowController
kcptunCheckBoxBtn.bind("value", to: editingProfile, withKeyPath: "enabledKcptun"
, options: [NSContinuouslyUpdatesValueBindingOption: true])
+ kcptunPortTextField.bind("value", to: editingProfile, withKeyPath: "serverPort"
+ , options: [NSContinuouslyUpdatesValueBindingOption: true])
+
kcptunProfileBox.bind("Hidden", to: editingProfile, withKeyPath: "enabledKcptun"
, options: [NSContinuouslyUpdatesValueBindingOption: false,
NSValueTransformerNameBindingOption: NSValueTransformerName.negateBooleanTransformerName])