diff --git a/buddi/buddiApp.swift b/buddi/buddiApp.swift index e222c21..60fc888 100644 --- a/buddi/buddiApp.swift +++ b/buddi/buddiApp.swift @@ -77,6 +77,11 @@ class AppDelegate: NSObject, NSApplicationDelegate { return false } + func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { + SettingsWindowController.shared.showWindow() + return true + } + func applicationWillTerminate(_ notification: Notification) { NotificationCenter.default.removeObserver(self) if let observer = screenLockedObserver { @@ -475,6 +480,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } + NSApp.setActivationPolicy(Defaults[.showInDock] ? .regular : .accessory) + previousScreens = NSScreen.screens HookInstaller.installIfNeeded() BuddiSessionBridge.shared.startMonitoring() diff --git a/buddi/components/Settings/SettingsView.swift b/buddi/components/Settings/SettingsView.swift index 15c13c3..5016bdb 100644 --- a/buddi/components/Settings/SettingsView.swift +++ b/buddi/components/Settings/SettingsView.swift @@ -151,7 +151,7 @@ struct GeneralSettings: View { @Default(.automaticallySwitchDisplay) var automaticallySwitchDisplay @Default(.enableGestures) var enableGestures @Default(.openNotchOnHover) var openNotchOnHover - + var body: some View { Form { @@ -163,6 +163,9 @@ struct GeneralSettings: View { Text("Show menu bar icon") } .tint(.effectiveAccent) + Defaults.Toggle(key: .showInDock) { + Text("Show in Dock") + } LaunchAtLogin.Toggle("Launch at login") Defaults.Toggle(key: .showOnAllDisplays) { Text("Show on all displays") diff --git a/buddi/components/Settings/SettingsWindowController.swift b/buddi/components/Settings/SettingsWindowController.swift index 0c4749d..ca86562 100644 --- a/buddi/components/Settings/SettingsWindowController.swift +++ b/buddi/components/Settings/SettingsWindowController.swift @@ -98,9 +98,7 @@ class SettingsWindowController: NSWindowController { private func relinquishFocus() { window?.orderOut(nil) - - // Set app back to accessory mode immediately - NSApp.setActivationPolicy(.accessory) + NSApp.setActivationPolicy(Defaults[.showInDock] ? .regular : .accessory) } } diff --git a/buddi/models/BuddiViewModel.swift b/buddi/models/BuddiViewModel.swift index 242c628..2c8ea99 100644 --- a/buddi/models/BuddiViewModel.swift +++ b/buddi/models/BuddiViewModel.swift @@ -184,7 +184,7 @@ class BuddiViewModel: NSObject, ObservableObject { } } - NSApp.setActivationPolicy(.accessory) + NSApp.setActivationPolicy(Defaults[.showInDock] ? .regular : .accessory) NSApp.deactivate() } diff --git a/buddi/models/Constants.swift b/buddi/models/Constants.swift index 960607b..d0dda58 100644 --- a/buddi/models/Constants.swift +++ b/buddi/models/Constants.swift @@ -70,6 +70,7 @@ enum OptionKeyAction: String, CaseIterable, Identifiable, Defaults.Serializable extension Defaults.Keys { // MARK: General static let menubarIcon = Key("menubarIcon", default: true) + static let showInDock = Key("showInDock", default: false) static let showOnAllDisplays = Key("showOnAllDisplays", default: false) static let automaticallySwitchDisplay = Key("automaticallySwitchDisplay", default: true) static let releaseName = Key("releaseName", default: "Uncommon Robot (Target Wizard)")