Skip to content

Commit

Permalink
Disable the "Launch At Login" preference when menu bar mode is not en…
Browse files Browse the repository at this point in the history
…abled
  • Loading branch information
sindresorhus committed Aug 6, 2021
1 parent ed08d28 commit 6367b03
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Color Picker/Events.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import SwiftUI
import Defaults
import KeyboardShortcuts
import LaunchAtLogin

extension AppState {
func setUpEvents() {
Expand All @@ -16,6 +17,7 @@ extension AppState {
NSApp.activate(ignoringOtherApps: true)

if !$0.newValue {
LaunchAtLogin.isEnabled = false
self.colorPanel.makeKeyAndOrderFront(nil)
}
}
Expand Down
17 changes: 15 additions & 2 deletions Color Picker/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ private struct ShowInMenuBarSetting: View {
return
}

isShowingTip = true
// isShowingTip = true

// TODO: The SwiftUI alert shows multiple times. (macOS 11.5)
DispatchQueue.main.async {
NSAlert.showModal(
title: "Tips",
message: "Click the menu bar icon to toggle the color picker window.\n\nRight-click the menu bar icon to quit the app or access the preferences."
)
}
}
.alert(isPresented: $isShowingTip) {
Alert(
Expand Down Expand Up @@ -60,11 +68,16 @@ private struct ShownColorFormatsSetting: View {
}

private struct GeneralSettings: View {
@Default(.showInMenuBar) private var showInMenuBar

var body: some View {
Form {
VStack(alignment: .leading) {
LaunchAtLogin.Toggle()
ShowInMenuBarSetting()
LaunchAtLogin.Toggle()
.disabled(!showInMenuBar)
.help(showInMenuBar ? "" : "There is really no point in launching the app at login if it is not in the menu bar. You can instead just put it in the Dock and launch it when needed.")
.padding(.leading, 17)
Defaults.Toggle("Stay on top", key: .stayOnTop)
.help("Make the color picker window stay on top of all other windows.")
Defaults.Toggle("Uppercase Hex color", key: .uppercaseHexColor)
Expand Down
2 changes: 2 additions & 0 deletions Color Picker/WelcomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ extension AppState {
message:
"""
If you have any feedback, bug reports, or feature requests, use the feedback button in the “Help” menu. I quickly respond to all submissions.
Bug reports through app reviews are ignored.
""",
buttonTitles: [
"Get Started"
Expand Down

0 comments on commit 6367b03

Please sign in to comment.