feat: add destination-specific global shortcuts
This commit is contained in:
@@ -92,8 +92,13 @@ struct ConjureApp {
|
||||
private final class ApplicationDelegate: NSObject, NSApplicationDelegate {
|
||||
private let uninstaller = ApplicationUninstaller()
|
||||
private lazy var launcher = LauncherWindowController(uninstaller: uninstaller)
|
||||
private lazy var shortcut = GlobalShortcut { [weak self] in self?.launcher.toggle() }
|
||||
private lazy var settings = SettingsWindowController(shortcut: shortcut)
|
||||
private lazy var shortcuts = GlobalShortcuts { [weak self] destination in
|
||||
switch destination {
|
||||
case .launcher: self?.launcher.toggle()
|
||||
case .command(let command): self?.launcher.toggle(command: command)
|
||||
}
|
||||
}
|
||||
private lazy var settings = SettingsWindowController(shortcuts: shortcuts)
|
||||
private var startupShortcutError: String?
|
||||
private var startupRecoveryMessage: String?
|
||||
|
||||
@@ -123,13 +128,10 @@ private final class ApplicationDelegate: NSObject, NSApplicationDelegate {
|
||||
if !isLoginLaunch {
|
||||
launcher.present()
|
||||
}
|
||||
do {
|
||||
try shortcut.start()
|
||||
} catch {
|
||||
startupShortcutError = error.localizedDescription
|
||||
if !isLoginLaunch {
|
||||
showSettings(nil)
|
||||
}
|
||||
let shortcutErrors = shortcuts.start()
|
||||
if !shortcutErrors.isEmpty {
|
||||
startupShortcutError = shortcutErrors.joined(separator: "\n")
|
||||
if !isLoginLaunch { showSettings(nil) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +151,7 @@ private final class ApplicationDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ notification: Notification) {
|
||||
shortcut.stop()
|
||||
shortcuts.stop()
|
||||
}
|
||||
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
|
||||
Reference in New Issue
Block a user