Feature: add icon

This commit is contained in:
yichengchen 2018-06-23 14:27:04 +08:00
parent fa1c418e82
commit 2ceeb2f21c
8 changed files with 17 additions and 9 deletions

View File

@ -26,9 +26,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
_ = ProxyConfigManager.install() _ = ProxyConfigManager.install()
statusItem = NSStatusBar.system.statusItem(withLength: AppDelegate.StatusItemIconWidth) statusItem = NSStatusBar.system.statusItem(withLength: AppDelegate.StatusItemIconWidth)
let image : NSImage = NSImage(named: NSImage.Name(rawValue: "menu_icon"))!
image.isTemplate = true
statusItem.image = image
statusItem.menu = statusMenu statusItem.menu = statusMenu
updateMenuItem() updateMenuItem()
startProxy() startProxy()
@ -44,7 +41,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func updateMenuItem(){ func updateMenuItem(){
proxySettingMenuItem.state = ConfigManager.proxyPortAutoSet ? .on : .off proxySettingMenuItem.state = ConfigManager.proxyPortAutoSet ? .on : .off
autoStartMenuItem.state = LaunchAtLogin.isEnabled ? .on:.off autoStartMenuItem.state = LaunchAtLogin.isEnabled ? .on:.off
let image = proxySettingMenuItem.state == .on ?
NSImage(named: NSImage.Name(rawValue: "menu_icon"))! :
NSImage(named: NSImage.Name(rawValue: "menu_icon_disabled"))!
statusItem.image = image
} }
func startProxy() { func startProxy() {
@ -93,8 +94,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@IBAction func actionGenConfig(_ sender: Any) { @IBAction func actionGenConfig(_ sender: Any) {
let ctrl = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil) let ctrl = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil)
.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "sampleConfigGenerator")) as! NSWindowController .instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "sampleConfigGenerator")) as! NSWindowController
genConfigWindow?.close() genConfigWindow?.close()
genConfigWindow=ctrl genConfigWindow=ctrl
ctrl.window?.title = ctrl.contentViewController?.title ?? ""
ctrl.showWindow(nil) ctrl.showWindow(nil)
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
ctrl.window?.makeKeyAndOrderFront(self) ctrl.window?.makeKeyAndOrderFront(self)

View File

@ -21,28 +21,33 @@
"scale" : "2x" "scale" : "2x"
}, },
{ {
"idiom" : "mac",
"size" : "128x128", "size" : "128x128",
"idiom" : "mac",
"filename" : "logo@128.png",
"scale" : "1x" "scale" : "1x"
}, },
{ {
"idiom" : "mac",
"size" : "128x128", "size" : "128x128",
"idiom" : "mac",
"filename" : "logo@256-1.png",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"idiom" : "mac",
"size" : "256x256", "size" : "256x256",
"idiom" : "mac",
"filename" : "logo@256.png",
"scale" : "1x" "scale" : "1x"
}, },
{ {
"idiom" : "mac",
"size" : "256x256", "size" : "256x256",
"idiom" : "mac",
"filename" : "logo@512-2.png",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"idiom" : "mac",
"size" : "512x512", "size" : "512x512",
"idiom" : "mac",
"filename" : "logo@512-1.png",
"scale" : "1x" "scale" : "1x"
}, },
{ {

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

@ -1 +1 @@
Subproject commit 7dcb8330f06b4789b7b172f6371dcdc22e4aa2ab Subproject commit 0193d1377f6d424e6712dda1e1fa3d4667b37bd3