Skip to content

Commit 0535cca

Browse files
committed
Add setting to quit after picking color
1 parent 452bec8 commit 0535cca

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

Color Picker/AppState.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ final class AppState: ObservableObject {
193193
if NSEvent.modifiers == .shift {
194194
pickColor()
195195
}
196+
197+
if
198+
Defaults[.quitAfterPicking],
199+
Defaults[.copyColorAfterPicking],
200+
!Defaults[.showInMenuBar]
201+
{
202+
SSApp.quit()
203+
}
196204
}
197205
}
198206

Color Picker/Constants.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extension Defaults.Keys {
2121
static let shownColorFormats = Key<Set<ColorFormat>>("shownColorFormats", default: [.hex, .hsl, .rgb, .lch])
2222
static let largerText = Key<Bool>("largerText", default: false)
2323
static let copyColorAfterPicking = Key<Bool>("copyColorAfterPicking", default: false)
24+
static let quitAfterPicking = Key<Bool>("quitAfterPicking", default: false)
2425
static let showAccessibilityColorName = Key<Bool>("showAccessibilityColorName", default: false)
2526
static let stickyPaletteName = Key<String?>("stickyPaletteName")
2627
}

Color Picker/SettingsScreen.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct SettingsScreen: View {
2828

2929
private struct GeneralSettings: View {
3030
@Default(.showInMenuBar) private var showInMenuBar
31+
@Default(.copyColorAfterPicking) private var copyColorAfterPicking
3132

3233
var body: some View {
3334
Form {
@@ -45,6 +46,12 @@ private struct GeneralSettings: View {
4546
Defaults.Toggle("Stay on top", key: .stayOnTop)
4647
.help("Make the color picker window stay on top of all other windows.")
4748
Defaults.Toggle("Copy color in preferred format after picking", key: .copyColorAfterPicking)
49+
if
50+
copyColorAfterPicking,
51+
!showInMenuBar
52+
{
53+
Defaults.Toggle("Quit after picking", key: .quitAfterPicking)
54+
}
4855
}
4956
Section {} footer: {
5057
Button("Feedback & Support") {

0 commit comments

Comments
 (0)