diff --git a/V2rayU/Base.lproj/ConfigWindow.xib b/V2rayU/Base.lproj/ConfigWindow.xib index e9d54cf..8fcacb6 100644 --- a/V2rayU/Base.lproj/ConfigWindow.xib +++ b/V2rayU/Base.lproj/ConfigWindow.xib @@ -15,16 +15,16 @@ - + - - + + - + @@ -36,8 +36,7 @@ - - + @@ -51,7 +50,7 @@ - + @@ -64,7 +63,7 @@ - + @@ -142,7 +141,7 @@ - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1526,50 +1524,6 @@ Gw - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1588,21 +1542,56 @@ Gw - + + + - + diff --git a/V2rayU/ConfigWindow.swift b/V2rayU/ConfigWindow.swift index eea48d6..8554164 100644 --- a/V2rayU/ConfigWindow.swift +++ b/V2rayU/ConfigWindow.swift @@ -29,12 +29,12 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel @IBOutlet weak var selectFileBtn: NSButton! @IBOutlet weak var importBtn: NSButton! - @IBOutlet weak var sockPort: NSTextField! - @IBOutlet weak var httpPort: NSTextField! - @IBOutlet weak var dnsServers: NSTextField! + @IBOutlet weak var sockPort: NSButton! + @IBOutlet weak var httpPort: NSButton! + @IBOutlet weak var dnsServers: NSButton! @IBOutlet weak var enableUdp: NSButton! @IBOutlet weak var enableMux: NSButton! - @IBOutlet weak var muxConcurrent: NSTextField! + @IBOutlet weak var muxConcurrent: NSButton! @IBOutlet weak var version4: NSButton! @IBOutlet weak var switchProtocol: NSPopUpButton! @@ -125,11 +125,6 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel self.serversTableView.reloadData() // tab view self.tabView.delegate = self - - // log level - if let level = UserDefaults.get(forKey: .v2rayLogLevel) { - logLevel.selectItem(withTitle: level) - } } @IBAction func addRemoveServer(_ sender: NSSegmentedCell) { @@ -246,13 +241,13 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel func exportData() { // ========================== base start ======================= // base - v2rayConfig.httpPort = self.httpPort.stringValue.replacingOccurrences(of: ",", with: "") - v2rayConfig.socksPort = self.sockPort.stringValue.replacingOccurrences(of: ",", with: "") - v2rayConfig.enableUdp = self.enableUdp.state.rawValue > 0 - v2rayConfig.enableMux = self.enableMux.state.rawValue > 0 - v2rayConfig.dns = self.dnsServers.stringValue - v2rayConfig.mux = Int(self.muxConcurrent.intValue) - v2rayConfig.isNewVersion = self.version4.state.rawValue > 0 +// v2rayConfig.httpPort = self.httpPort.stringValue.replacingOccurrences(of: ",", with: "") +// v2rayConfig.socksPort = self.sockPort.stringValue.replacingOccurrences(of: ",", with: "") +// v2rayConfig.enableUdp = self.enableUdp.state.rawValue > 0 +// v2rayConfig.enableMux = self.enableMux.state.rawValue > 0 +// v2rayConfig.dns = self.dnsServers.stringValue +// v2rayConfig.mux = Int(self.muxConcurrent.intValue) +// v2rayConfig.isNewVersion = self.version4.state.rawValue > 0 // ========================== base end ======================= // ========================== server start ======================= @@ -343,12 +338,13 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel func bindDataToView() { // ========================== base start ======================= // base - self.httpPort.stringValue = v2rayConfig.httpPort - self.sockPort.stringValue = v2rayConfig.socksPort + print("bindDataToView", v2rayConfig.httpPort, v2rayConfig.socksPort, v2rayConfig.dns) + self.httpPort.title = v2rayConfig.httpPort + self.sockPort.title = v2rayConfig.socksPort self.enableUdp.intValue = v2rayConfig.enableUdp ? 1 : 0 self.enableMux.intValue = v2rayConfig.enableMux ? 1 : 0 self.muxConcurrent.intValue = Int32(v2rayConfig.mux) - self.dnsServers.stringValue = v2rayConfig.dns + self.dnsServers.title = v2rayConfig.dns self.version4.intValue = v2rayConfig.isNewVersion ? 1 : 0 // ========================== base end ======================= @@ -591,6 +587,13 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel NSWorkspace.shared.open(url) } + @IBAction func goVersionHelp(_ sender: Any) { + guard let url = URL(string: "https://www.v2ray.com/chapter_02/01_overview.html") else { + return + } + NSWorkspace.shared.open(url) + } + @IBAction func goStreamHelp(_ sender: Any) { guard let url = URL(string: "https://www.v2ray.com/chapter_02/05_transport.html") else { return @@ -708,15 +711,23 @@ class ConfigWindowController: NSWindowController, NSWindowDelegate, NSTabViewDel @IBAction func openLogs(_ sender: NSButton) { V2rayLaunch.OpenLogs() } - + @IBAction func clearLogs(_ sender: NSButton) { V2rayLaunch.ClearLogs() } - + @IBAction func cancel(_ sender: NSButton) { // hide dock icon and close all opened windows menuController.hideDock() } + + @IBAction func goAdvanceSetting(_ sender: Any) { + preferencesWindowController.show(preferencePane: .advanceTab) + } + + @IBAction func goSubscriptSetting(_ sender: Any) { + preferencesWindowController.show(preferencePane: .subscriptTab) + } } // NSv2rayItemListSource diff --git a/V2rayU/Preference/PreferenceAdvance.swift b/V2rayU/Preference/PreferenceAdvance.swift index d155774..a390daf 100644 --- a/V2rayU/Preference/PreferenceAdvance.swift +++ b/V2rayU/Preference/PreferenceAdvance.swift @@ -14,6 +14,14 @@ final class PreferenceAdvanceViewController: NSViewController, PreferencePane { let preferencePaneTitle = "Advance" let toolbarItemIcon = NSImage(named: NSImage.advancedName)! + @IBOutlet weak var sockPort: NSTextField! + @IBOutlet weak var httpPort: NSTextField! + @IBOutlet weak var dnsServers: NSTextField! + @IBOutlet weak var pacPort: NSTextField! + @IBOutlet weak var enableUdp: NSButton! + @IBOutlet weak var enableMux: NSButton! + @IBOutlet weak var muxConcurrent: NSTextField! + override var nibName: NSNib.Name? { return "PreferenceAdvance" } @@ -23,4 +31,6 @@ final class PreferenceAdvanceViewController: NSViewController, PreferencePane { // fix: https://github.com/sindresorhus/Preferences/issues/31 self.preferredContentSize = NSMakeSize(self.view.frame.size.width, self.view.frame.size.height); } + + } diff --git a/V2rayU/Preference/PreferenceAdvance.xib b/V2rayU/Preference/PreferenceAdvance.xib index a691af5..2d1592e 100755 --- a/V2rayU/Preference/PreferenceAdvance.xib +++ b/V2rayU/Preference/PreferenceAdvance.xib @@ -8,50 +8,39 @@ + + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - + - + @@ -71,17 +60,8 @@ - - - - - - - - - - + @@ -93,19 +73,29 @@ - - + + + + + + + + + + + - + - - + + - + + @@ -115,27 +105,75 @@ - - + + - + - - + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -148,9 +186,8 @@ - + - diff --git a/V2rayU/Preference/PreferenceGeneral.swift b/V2rayU/Preference/PreferenceGeneral.swift index c552934..a102967 100644 --- a/V2rayU/Preference/PreferenceGeneral.swift +++ b/V2rayU/Preference/PreferenceGeneral.swift @@ -21,7 +21,8 @@ final class PreferenceGeneralViewController: NSViewController, PreferencePane { @IBOutlet weak var autoLaunch: NSButtonCell! @IBOutlet weak var autoCheckVersion: NSButtonCell! - + @IBOutlet weak var autoClearLog: NSButtonCell! + override func viewDidLoad() { super.viewDidLoad() // fix: https://github.com/sindresorhus/Preferences/issues/31 @@ -29,12 +30,16 @@ final class PreferenceGeneralViewController: NSViewController, PreferencePane { let autoLaunchState = UserDefaults.getBool(forKey: .autoLaunch) let autoCheckVersionState = UserDefaults.getBool(forKey: .autoCheckVersion) + let autoClearLogState = UserDefaults.getBool(forKey: .autoClearLog) if autoLaunchState { autoLaunch.state = .on } if autoCheckVersionState { autoCheckVersion.state = .on } + if autoClearLogState { + autoClearLog.state = .on + } } @IBAction func SetAutoLogin(_ sender: NSButtonCell) { @@ -46,20 +51,10 @@ final class PreferenceGeneralViewController: NSViewController, PreferencePane { UserDefaults.setBool(forKey: .autoCheckVersion, value: sender.state == .on) } - @IBAction func goWebsite(_ sender: NSButton) { - guard let url = URL(string: "https://yanue.github.io/V2rayU/") else { - return - } - NSWorkspace.shared.open(url) + @IBAction func SetAutoClearLogs(_ sender: NSButtonCell) { + UserDefaults.setBool(forKey: .autoClearLog, value: sender.state == .on) } - - @IBAction func goV2ray(_ sender: NSButton) { - guard let url = URL(string: "https://github.com/v2ray/v2ray-core") else { - return - } - NSWorkspace.shared.open(url) - } - + @IBAction func goFeedback(_ sender: NSButton) { guard let url = URL(string: "https://github.com/yanue/v2rayu/issues") else { return @@ -71,4 +66,12 @@ final class PreferenceGeneralViewController: NSViewController, PreferencePane { // need set SUFeedURL into plist V2rayUpdater.checkForUpdates(sender) } + + @IBAction func openLogs(_ sender: NSButton) { + V2rayLaunch.OpenLogs() + } + + @IBAction func clearLogs(_ sender: NSButton) { + V2rayLaunch.ClearLogs() + } } diff --git a/V2rayU/Preference/PreferenceGeneral.xib b/V2rayU/Preference/PreferenceGeneral.xib index bda3c10..5cdd7ff 100755 --- a/V2rayU/Preference/PreferenceGeneral.xib +++ b/V2rayU/Preference/PreferenceGeneral.xib @@ -9,17 +9,18 @@ + - + - + + + + + + + + + + + + + + + - + diff --git a/V2rayU/Preference/PreferenceSubscript.xib b/V2rayU/Preference/PreferenceSubscript.xib index e5f5195..a086c84 100755 --- a/V2rayU/Preference/PreferenceSubscript.xib +++ b/V2rayU/Preference/PreferenceSubscript.xib @@ -79,7 +79,7 @@ - + diff --git a/V2rayU/Util.swift b/V2rayU/Util.swift index 56ce489..3db1b49 100644 --- a/V2rayU/Util.swift +++ b/V2rayU/Util.swift @@ -27,6 +27,8 @@ extension UserDefaults { case autoCheckVersion // auto launch after login case autoLaunch + // auto clear logs + case autoClearLog // pac|manual|global case runMode // use rules