From 2f38f95f55c62ef7c319e867444885458d4376c0 Mon Sep 17 00:00:00 2001 From: qinyuhang Date: Thu, 15 Sep 2016 16:22:02 +0800 Subject: [PATCH] fix bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正服务器设置面板不能拷贝到剪切板的bug 重新组织了AppDelegate的结构 修正travis-ci报错问题 --- .travis.yml | 2 +- ShadowsocksX-NG.xcodeproj/project.pbxproj | 9 ++--- ShadowsocksX-NG/AppDelegate.swift | 34 +++++++++++-------- ShadowsocksX-NG/PingTest.swift | 4 --- .../PreferencesWindowController.swift | 5 ++- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index e218bfe..fa9998b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ language: objective-c osx_image: xcode7.3 xcode_workspace: ShadowsocksX-NG.xcworkspace xcode_scheme: ShadowsocksX-NG -script: set -o pipefail && xcodebuild test -workspace ShadowsocksX-NG.xcworkspace -scheme ShadowsocksX-NG|xcpretty +script: set -o pipefail && xcodebuild test -workspace ShadowsocksX-NG.xcworkspace -scheme ShadowsocksX-NG -sdk macosx10.12 CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO|xcpretty diff --git a/ShadowsocksX-NG.xcodeproj/project.pbxproj b/ShadowsocksX-NG.xcodeproj/project.pbxproj index a8bc040..8b0ebff 100644 --- a/ShadowsocksX-NG.xcodeproj/project.pbxproj +++ b/ShadowsocksX-NG.xcodeproj/project.pbxproj @@ -452,7 +452,8 @@ TargetAttributes = { 9B0BFFE41D0460A70040E62B = { CreatedOnToolsVersion = 7.3.1; - ProvisioningStyle = Manual; + DevelopmentTeam = 2E8Q4BTFR2; + ProvisioningStyle = Automatic; }; 9B0BFFF31D0460A70040E62B = { CreatedOnToolsVersion = 7.3.1; @@ -861,9 +862,9 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "Developer ID Application"; + CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 2E8Q4BTFR2; HEADER_SEARCH_PATHS = ( "$(SRCROOT)/libcork/include/", "$(SRCROOT)/libipset/include/", @@ -893,7 +894,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 2E8Q4BTFR2; HEADER_SEARCH_PATHS = ( "$(SRCROOT)/libcork/include/", "$(SRCROOT)/libipset/include/", diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index cdb76e0..73f1da9 100644 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -11,15 +11,17 @@ import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate { - + + // MARK: Controllers var qrcodeWinCtrl: SWBQRCodeWindowController! var preferencesWinCtrl: PreferencesWindowController! var advPreferencesWinCtrl: AdvPreferencesWindowController! var proxyPreferencesWinCtrl: ProxyPreferencesController! var editUserRulesWinCtrl: UserRulesController! - + var launchAtLoginController: LaunchAtLoginController = LaunchAtLoginController() + // MARK: Outlets @IBOutlet weak var window: NSWindow! @IBOutlet weak var statusMenu: NSMenu! @@ -46,6 +48,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele @IBOutlet weak var connectAtLaunchMenuItem: NSMenuItem! @IBOutlet weak var ShowNetworkSpeedItem: NSMenuItem! + // MARK: Variables var statusItemView:StatusItemView! var statusItem: NSStatusItem? @@ -236,7 +239,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele } - // MARK: interface functions + // MARK: Mainmenu functions @IBAction func toggleRunning(sender: NSMenuItem) { let defaults = NSUserDefaults.standardUserDefaults() @@ -269,6 +272,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele ctrl.window?.makeKeyAndOrderFront(self) } + @IBAction func toggleLaunghAtLogin(sender: NSMenuItem) { + launchAtLoginController.launchAtLogin = !launchAtLoginController.launchAtLogin; + updateLaunchAtLoginMenu() + } + + @IBAction func toggleConnectAtLaunch(sender: NSMenuItem) { + let defaults = NSUserDefaults.standardUserDefaults() + defaults.setBool(!defaults.boolForKey("ConnectAtLaunch"), forKey: "ConnectAtLaunch") + updateMainMenu() + } + + // MARK: Server submenu function @IBAction func showQRCodeForCurrentServer(sender: NSMenuItem) { var errMsg: String? if let profile = ServerProfileManager.instance.getActiveProfile() { @@ -314,17 +329,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele @IBAction func exportAllServerProfile(sender: NSMenuItem) { ServerProfileManager.instance.exportConfigFile() } - - @IBAction func toggleLaunghAtLogin(sender: NSMenuItem) { - launchAtLoginController.launchAtLogin = !launchAtLoginController.launchAtLogin; - updateLaunchAtLoginMenu() - } - - @IBAction func toggleConnectAtLaunch(sender: NSMenuItem) { - let defaults = NSUserDefaults.standardUserDefaults() - defaults.setBool(!defaults.boolForKey("ConnectAtLaunch"), forKey: "ConnectAtLaunch") - updateMainMenu() - } @IBAction func selectPACMode(sender: NSMenuItem) { let defaults = NSUserDefaults.standardUserDefaults() @@ -636,7 +640,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele } //------------------------------------------------------------ - // NSUserNotificationCenterDelegate + // MARK: NSUserNotificationCenterDelegate func userNotificationCenter(center: NSUserNotificationCenter , shouldPresentNotification notification: NSUserNotification) -> Bool { diff --git a/ShadowsocksX-NG/PingTest.swift b/ShadowsocksX-NG/PingTest.swift index ea18648..75aa054 100644 --- a/ShadowsocksX-NG/PingTest.swift +++ b/ShadowsocksX-NG/PingTest.swift @@ -160,10 +160,6 @@ class PingTest: NSObject, SimplePingDelegate { } class func pingArray(){//hostList : [String]) -> [[String : String]]{ // return [["apple.com":"20"],["baidu.com":"20"]] - - - - } } diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 842640f..99cf659 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -172,11 +172,10 @@ class PreferencesWindowController: NSWindowController let profile = profileMgr.profiles[index] let ssURL = profile.URL() if let url = ssURL { - // Then copy url to pasteboard - // TODO Why it not working?? It's ok in objective-c + let pboard = NSPasteboard.generalPasteboard() pboard.clearContents() - let rs = pboard.writeObjects([url]) + let rs = pboard.setString(String(url), forType: NSStringPboardType)//writeObjects([url]) if rs { NSLog("copy to pasteboard success") } else {