Skip to content
Closed
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 Sources/Pesty/Settings/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) }
}
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions Sources/Pesty/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion Sources/Pesty/UI/BarWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Loading