|
|
@ -7,18 +7,15 @@ open class AppDelegate : NSObject, NSApplicationDelegate { |
|
|
|
lazy private var floatingWindow: FloatingWindowController = FloatingWindowController.shared() |
|
|
|
lazy private var floatingWindow: FloatingWindowController = FloatingWindowController.shared() |
|
|
|
lazy private var panelController: PanelController = PanelController.shared() |
|
|
|
lazy private var panelController: PanelController = PanelController.shared() |
|
|
|
private var statusBarHandler: StatusItemHandler! |
|
|
|
private var statusBarHandler: StatusItemHandler! |
|
|
|
|
|
|
|
private var panelObserver: NSKeyValueObservation? |
|
|
|
|
|
|
|
|
|
|
|
deinit { |
|
|
|
deinit { |
|
|
|
panelController.removeObserver(self, forKeyPath: "hasActivePanel") |
|
|
|
panelObserver?.invalidate() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private var kContextActivePanel = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { |
|
|
|
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { |
|
|
|
|
|
|
|
|
|
|
|
if context == &kContextActivePanel { |
|
|
|
if let path = keyPath, path == "values.globalPing" { |
|
|
|
statusBarHandler.setHasActiveIcon(panelController.hasActivePanelGetter()) |
|
|
|
|
|
|
|
} else if let path = keyPath, path == "values.globalPing" { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let hotKeyCenter = PTHotKeyCenter.shared() |
|
|
|
let hotKeyCenter = PTHotKeyCenter.shared() |
|
|
|
|
|
|
|
|
|
|
@ -129,10 +126,9 @@ open class AppDelegate : NSObject, NSApplicationDelegate { |
|
|
|
|
|
|
|
|
|
|
|
assignShortcut() |
|
|
|
assignShortcut() |
|
|
|
|
|
|
|
|
|
|
|
panelController.addObserver(self, |
|
|
|
panelObserver = panelController.observe(\.hasActivePanel, options: [.new]) { (obj, change) in |
|
|
|
forKeyPath: "hasActivePanel", |
|
|
|
self.statusBarHandler.setHasActiveIcon(obj.hasActivePanelGetter()) |
|
|
|
options: [.new], |
|
|
|
} |
|
|
|
context: &kContextActivePanel) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let defaults = UserDefaults.standard |
|
|
|
let defaults = UserDefaults.standard |
|
|
|
|
|
|
|
|
|
|
|