conversion to swift 5 by xcode

This commit is contained in:
Qiu Yuzhou
2021-06-24 01:18:55 +08:00
parent 18f6c4ad80
commit b59b53940c
3 changed files with 23 additions and 23 deletions
+3 -3
View File
@@ -607,7 +607,7 @@
9B0BFFE41D0460A70040E62B = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = RJX3H8KBAF;
LastSwiftMigration = 0900;
LastSwiftMigration = 1250;
ProvisioningStyle = Automatic;
};
9B3FFF431D09CD3B0019A709 = {
@@ -1072,7 +1072,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "ShadowsocksX-NG/ShadowsocksX-NG-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -1106,7 +1106,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "ShadowsocksX-NG/ShadowsocksX-NG-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
+16 -16
View File
@@ -115,7 +115,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
])
statusItem = NSStatusBar.system.statusItem(withLength: AppDelegate.StatusItemIconWidth)
let image : NSImage = NSImage(named: NSImage.Name(rawValue: "menu_icon"))!
let image : NSImage = NSImage(named: "menu_icon")!
image.isTemplate = true
statusItem.image = image
statusItem.menu = statusMenu
@@ -282,7 +282,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if editUserRulesWinCtrl != nil {
editUserRulesWinCtrl.close()
}
let ctrl = UserRulesController(windowNibName: NSNib.Name(rawValue: "UserRulesController"))
let ctrl = UserRulesController(windowNibName: "UserRulesController")
editUserRulesWinCtrl = ctrl
ctrl.showWindow(self)
@@ -294,7 +294,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if shareWinCtrl != nil {
shareWinCtrl.close()
}
shareWinCtrl = ShareServerProfilesWindowController(windowNibName: NSNib.Name(rawValue: "ShareServerProfilesWindowController"))
shareWinCtrl = ShareServerProfilesWindowController(windowNibName: "ShareServerProfilesWindowController")
shareWinCtrl.showWindow(self)
NSApp.activate(ignoringOtherApps: true)
shareWinCtrl.window?.makeKeyAndOrderFront(nil)
@@ -304,7 +304,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if importWinCtrl != nil {
importWinCtrl.close()
}
importWinCtrl = ImportWindowController(windowNibName: .init(rawValue: "ImportWindowController"))
importWinCtrl = ImportWindowController(windowNibName: "ImportWindowController")
importWinCtrl.showWindow(self)
NSApp.activate(ignoringOtherApps: true)
importWinCtrl.window?.makeKeyAndOrderFront(nil)
@@ -377,7 +377,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if preferencesWinCtrl != nil {
preferencesWinCtrl.close()
}
preferencesWinCtrl = PreferencesWindowController(windowNibName: NSNib.Name(rawValue: "PreferencesWindowController"))
preferencesWinCtrl = PreferencesWindowController(windowNibName: "PreferencesWindowController")
preferencesWinCtrl.showWindow(self)
NSApp.activate(ignoringOtherApps: true)
@@ -388,7 +388,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
allInOnePreferencesWinCtrl.close()
}
allInOnePreferencesWinCtrl = PreferencesWinController(windowNibName: NSNib.Name(rawValue: "PreferencesWinController"))
allInOnePreferencesWinCtrl = PreferencesWinController(windowNibName: "PreferencesWinController")
allInOnePreferencesWinCtrl.showWindow(self)
NSApp.activate(ignoringOtherApps: true)
@@ -530,19 +530,19 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if let m = mode {
switch m {
case "auto":
statusItem.image = NSImage(named: NSImage.Name(rawValue: "menu_p_icon"))
statusItem.image = NSImage(named: "menu_p_icon")
case "global":
statusItem.image = NSImage(named: NSImage.Name(rawValue: "menu_g_icon"))
statusItem.image = NSImage(named: "menu_g_icon")
case "manual":
statusItem.image = NSImage(named: NSImage.Name(rawValue: "menu_m_icon"))
statusItem.image = NSImage(named: "menu_m_icon")
case "externalPAC":
statusItem.image = NSImage(named: NSImage.Name(rawValue: "menu_e_icon"))
statusItem.image = NSImage(named: "menu_e_icon")
default: break
}
statusItem.image?.isTemplate = true
}
} else {
statusItem.image = NSImage(named: NSImage.Name(rawValue: "menu_icon_disabled"))
statusItem.image = NSImage(named: "menu_icon_disabled")
statusItem.image?.isTemplate = true
}
}
@@ -552,15 +552,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
let isOn = defaults.bool(forKey: "ShadowsocksOn")
if isOn {
runningStatusMenuItem.title = "Shadowsocks: On".localized
runningStatusMenuItem.image = NSImage(named: NSImage.Name(rawValue: "NSStatusAvailable"))
runningStatusMenuItem.image = NSImage(named: "NSStatusAvailable")
toggleRunningMenuItem.title = "Turn Shadowsocks Off".localized
let image = NSImage(named: NSImage.Name(rawValue: "menu_icon"))
let image = NSImage(named: "menu_icon")
statusItem.image = image
} else {
runningStatusMenuItem.title = "Shadowsocks: Off".localized
toggleRunningMenuItem.title = "Turn Shadowsocks On".localized
runningStatusMenuItem.image = NSImage(named: NSImage.Name(rawValue: "NSStatusNone"))
let image = NSImage(named: NSImage.Name(rawValue: "menu_icon_disabled"))
runningStatusMenuItem.image = NSImage(named: "NSStatusNone")
let image = NSImage(named: "menu_icon_disabled")
statusItem.image = image
}
statusItem.image?.isTemplate = true
@@ -680,7 +680,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if toastWindowCtrl != nil {
toastWindowCtrl.close()
}
toastWindowCtrl = ToastWindowController(windowNibName: NSNib.Name(rawValue: "ToastWindowController"))
toastWindowCtrl = ToastWindowController(windowNibName: "ToastWindowController")
toastWindowCtrl.message = message
toastWindowCtrl.showWindow(self)
//NSApp.activate(ignoringOtherApps: true)
@@ -158,10 +158,10 @@ class PreferencesWindowController: NSWindowController
@IBAction func togglePasswordVisible(_ sender: Any) {
if passwordTabView.selectedTabViewItem?.identifier as! String == "secure" {
passwordTabView.selectTabViewItem(withIdentifier: "insecure")
togglePasswordVisibleButton.image = NSImage(named: NSImage.Name(rawValue: "icons8-Eye Filled-50"))
togglePasswordVisibleButton.image = NSImage(named: "icons8-Eye Filled-50")
} else {
passwordTabView.selectTabViewItem(withIdentifier: "secure")
togglePasswordVisibleButton.image = NSImage(named: NSImage.Name(rawValue: "icons8-Blind Filled-50"))
togglePasswordVisibleButton.image = NSImage(named: "icons8-Blind Filled-50")
}
}
@@ -277,7 +277,7 @@ class PreferencesWindowController: NSWindowController
return title
} else if tableColumn?.identifier == NSUserInterfaceItemIdentifier("status") {
if isActive {
return NSImage(named: NSImage.Name(rawValue: "NSMenuOnStateTemplate"))
return NSImage(named: "NSMenuOnStateTemplate")
} else {
return nil
}
@@ -390,7 +390,7 @@ class PreferencesWindowController: NSWindowController
shakePath.closeSubpath()
shakeAnimation.path = shakePath
shakeAnimation.duration = CFTimeInterval(durationOfShake)
window?.animations = [NSAnimatablePropertyKey(rawValue: "frameOrigin"):shakeAnimation]
window?.animations = ["frameOrigin":shakeAnimation]
window?.animator().setFrameOrigin(window!.frame.origin)
}
}