Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions buddi/buddiApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -475,6 +480,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

NSApp.setActivationPolicy(Defaults[.showInDock] ? .regular : .accessory)

previousScreens = NSScreen.screens
HookInstaller.installIfNeeded()
BuddiSessionBridge.shared.startMonitoring()
Expand Down
5 changes: 4 additions & 1 deletion buddi/components/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct GeneralSettings: View {
@Default(.automaticallySwitchDisplay) var automaticallySwitchDisplay
@Default(.enableGestures) var enableGestures
@Default(.openNotchOnHover) var openNotchOnHover


var body: some View {
Form {
Expand All @@ -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")
Expand Down
4 changes: 1 addition & 3 deletions buddi/components/Settings/SettingsWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion buddi/models/BuddiViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class BuddiViewModel: NSObject, ObservableObject {
}
}

NSApp.setActivationPolicy(.accessory)
NSApp.setActivationPolicy(Defaults[.showInDock] ? .regular : .accessory)
NSApp.deactivate()
}

Expand Down
1 change: 1 addition & 0 deletions buddi/models/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ enum OptionKeyAction: String, CaseIterable, Identifiable, Defaults.Serializable
extension Defaults.Keys {
// MARK: General
static let menubarIcon = Key<Bool>("menubarIcon", default: true)
static let showInDock = Key<Bool>("showInDock", default: false)
static let showOnAllDisplays = Key<Bool>("showOnAllDisplays", default: false)
static let automaticallySwitchDisplay = Key<Bool>("automaticallySwitchDisplay", default: true)
static let releaseName = Key<String>("releaseName", default: "Uncommon Robot (Target Wizard)")
Expand Down
Loading