Add KcptunProfile.

This commit is contained in:
Charlie Qiu
2017-01-12 15:04:08 +08:00
parent 361742ba38
commit ad938a355a
6 changed files with 407 additions and 100 deletions
@@ -14,6 +14,7 @@ class PreferencesWindowController: NSWindowController
@IBOutlet weak var profilesTableView: NSTableView!
@IBOutlet weak var profileBox: NSBox!
@IBOutlet weak var kcptunProfileBox: NSBox!
@IBOutlet weak var hostTextField: NSTextField!
@IBOutlet weak var portTextField: NSTextField!
@@ -24,7 +25,13 @@ class PreferencesWindowController: NSWindowController
@IBOutlet weak var otaCheckBoxBtn: NSButton!
@IBOutlet weak var copyURLBtn: NSButton!
@IBOutlet weak var kcptunCheckBoxBtn: NSButton!
@IBOutlet weak var kcptunCryptComboBox: NSComboBox!
@IBOutlet weak var kcptunKeyTextField: NSTextField!
@IBOutlet weak var kcptunModeComboBox: NSComboBox!
@IBOutlet weak var kcptunNocompCheckBoxBtn: NSButton!
@IBOutlet weak var kcptunDatashardTextField: NSTextField!
@IBOutlet weak var kcptunParityshardTextField: NSTextField!
@IBOutlet weak var removeButton: NSButton!
let tableViewDragType: String = "ss.server.profile.data"
@@ -63,6 +70,28 @@ class PreferencesWindowController: NSWindowController
"table",
])
kcptunCryptComboBox.addItems(withObjectValues: [
"none",
"aes",
"aes-128",
"aes-192",
"salsa20",
"blowfish",
"twofish",
"cast5",
"3des",
"tea",
"xtea",
"xor",
])
kcptunModeComboBox.addItems(withObjectValues: [
"default",
"normal",
"fast",
"fast2",
])
profilesTableView.reloadData()
updateProfileBoxVisible()
}
@@ -189,6 +218,31 @@ class PreferencesWindowController: NSWindowController
otaCheckBoxBtn.bind("value", to: editingProfile, withKeyPath: "ota"
, options: [NSContinuouslyUpdatesValueBindingOption: true])
// --------------------------------------------------
// Kcptun
kcptunCheckBoxBtn.bind("value", to: editingProfile, withKeyPath: "enabledKcptun"
, options: [NSContinuouslyUpdatesValueBindingOption: true])
kcptunProfileBox.bind("Hidden", to: editingProfile, withKeyPath: "enabledKcptun"
, options: [NSContinuouslyUpdatesValueBindingOption: false,
NSValueTransformerNameBindingOption: NSValueTransformerName.negateBooleanTransformerName])
kcptunNocompCheckBoxBtn.bind("value", to: editingProfile, withKeyPath: "kcptunProfile.nocomp", options: nil)
kcptunModeComboBox.bind("value", to: editingProfile, withKeyPath: "kcptunProfile.mode", options: nil)
kcptunCryptComboBox.bind("value", to: editingProfile, withKeyPath: "kcptunProfile.crypt", options: nil)
kcptunKeyTextField.bind("value", to: editingProfile, withKeyPath: "kcptunProfile.key"
, options: [NSContinuouslyUpdatesValueBindingOption: true])
kcptunDatashardTextField.bind("value", to: editingProfile, withKeyPath: "kcptunProfile.datashard"
, options: [NSContinuouslyUpdatesValueBindingOption: true])
kcptunParityshardTextField.bind("value", to: editingProfile, withKeyPath: "kcptunProfile.parityshard"
, options: [NSContinuouslyUpdatesValueBindingOption: true])
} else {
editingProfile = nil
hostTextField.unbind("value")
@@ -200,6 +254,8 @@ class PreferencesWindowController: NSWindowController
remarkTextField.unbind("value")
otaCheckBoxBtn.unbind("value")
kcptunCheckBoxBtn.unbind("value")
}
}