diff --git a/Sources/Pesty/Settings/Settings.swift b/Sources/Pesty/Settings/Settings.swift index c0b2a49..33306b9 100644 --- a/Sources/Pesty/Settings/Settings.swift +++ b/Sources/Pesty/Settings/Settings.swift @@ -15,6 +15,7 @@ final class Settings { static let hotkeyKeyCode = "hotkeyKeyCode" static let hotkeyModifiers = "hotkeyModifiers" static let launchAtLogin = "launchAtLogin" + static let hideOnClickOutside = "hideOnClickOutside" static let pasteDirectly = "pasteDirectly" static let playSound = "playSound" static let ignoreConcealed = "ignoreConcealed" @@ -47,6 +48,10 @@ final class Settings { d.set(launchAtLogin, forKey: Keys.launchAtLogin); LaunchAtLogin.set(enabled: launchAtLogin) } } + var hideOnClickOutside: Bool { + didSet { guard isLoaded else { return }; d.set(hideOnClickOutside, forKey: Keys.hideOnClickOutside) } + } + var pasteDirectly: Bool { didSet { guard isLoaded else { return }; d.set(pasteDirectly, forKey: Keys.pasteDirectly) } } @@ -82,6 +87,7 @@ final class Settings { Keys.hotkeyKeyCode: kVK_ANSI_V, Keys.hotkeyModifiers: cmdKey | shiftKey, Keys.launchAtLogin: false, + Keys.hideOnClickOutside: true, Keys.pasteDirectly: true, Keys.playSound: false, Keys.ignoreConcealed: true, @@ -93,6 +99,7 @@ final class Settings { hotkeyKeyCode = d.integer(forKey: Keys.hotkeyKeyCode) hotkeyModifiers = d.integer(forKey: Keys.hotkeyModifiers) launchAtLogin = d.bool(forKey: Keys.launchAtLogin) + hideOnClickOutside = d.bool(forKey: Keys.hideOnClickOutside) pasteDirectly = d.bool(forKey: Keys.pasteDirectly) playSound = d.bool(forKey: Keys.playSound) ignoreConcealed = d.bool(forKey: Keys.ignoreConcealed) diff --git a/Sources/Pesty/Settings/SettingsView.swift b/Sources/Pesty/Settings/SettingsView.swift index 2a08bbe..af8a85c 100644 --- a/Sources/Pesty/Settings/SettingsView.swift +++ b/Sources/Pesty/Settings/SettingsView.swift @@ -37,6 +37,7 @@ private struct GeneralSettings: View { #endif Toggle("Ignore passwords (concealed clips)", isOn: $settings.ignoreConcealed) Toggle("Play sound on paste", isOn: $settings.playSound) + Toggle("Hide Pesty when clicking outside", isOn: $settings.hideOnClickOutside) Toggle("Launch at login", isOn: $settings.launchAtLogin) VStack(alignment: .leading) { LabeledContent("Bar height", value: "\(Int(settings.barHeight)) px") diff --git a/Sources/Pesty/UI/BarWindowController.swift b/Sources/Pesty/UI/BarWindowController.swift index cbd1c2a..0553b90 100644 --- a/Sources/Pesty/UI/BarWindowController.swift +++ b/Sources/Pesty/UI/BarWindowController.swift @@ -69,7 +69,9 @@ final class BarWindowController: NSWindowController, NSWindowDelegate { } func windowDidResignKey(_ notification: Notification) { - guard !isPresenting, !AppController.shared.suppressAutoHide else { return } + guard Settings.shared.hideOnClickOutside, + !isPresenting, + !AppController.shared.suppressAutoHide else { return } AppController.shared.hideBar() } }