diff --git a/BrewBar/BrewBarApp.swift b/BrewBar/BrewBarApp.swift index e228628..df5552f 100644 --- a/BrewBar/BrewBarApp.swift +++ b/BrewBar/BrewBarApp.swift @@ -210,7 +210,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { } @objc func upgradeAll() { - guard confirmUpgrade() else { return } + if Settings.confirmBeforeUpgradeAll { + guard confirmUpgrade() else { return } + } statusMenuItem.title = "Upgrading..." diff --git a/BrewBar/SettingsWindowController.swift b/BrewBar/SettingsWindowController.swift index a959879..eb216d8 100644 --- a/BrewBar/SettingsWindowController.swift +++ b/BrewBar/SettingsWindowController.swift @@ -21,6 +21,7 @@ class SettingsWindowController: NSWindowController { var autoUpgradeCasksCheckbox: NSButton! var notifyCheckbox: NSButton! var showCountCheckbox: NSButton! + var confirmCheckbox: NSButton! convenience init(appDelegate: AppDelegate) { let window = NSWindow( @@ -123,6 +124,12 @@ class SettingsWindowController: NSWindowController { action: #selector(toggleShowCount(_:)) ) + confirmCheckbox = NSButton( + checkboxWithTitle: "Ask for confirmation before Upgrade All", + target: self, + action: #selector(toggleConfirm(_:)) + ) + let stack = NSStackView(views: [ frequencyRow, customRow, @@ -134,6 +141,7 @@ class SettingsWindowController: NSWindowController { separator(), notifyCheckbox, showCountCheckbox, + confirmCheckbox, launchAtLoginCheckbox, ]) stack.orientation = .vertical @@ -174,6 +182,7 @@ class SettingsWindowController: NSWindowController { autoUpgradeCasksCheckbox.state = Settings.autoUpgradeCasks ? .on : .off notifyCheckbox.state = Settings.notifyOnNewUpdates ? .on : .off showCountCheckbox.state = Settings.showCountInMenuBar ? .on : .off + confirmCheckbox.state = Settings.confirmBeforeUpgradeAll ? .on : .off } func separator() -> NSBox { @@ -239,6 +248,10 @@ class SettingsWindowController: NSWindowController { appDelegate?.updateMenuBarCount() // reflect immediately, no refetch needed } + @objc func toggleConfirm(_ sender: NSButton) { + Settings.confirmBeforeUpgradeAll = sender.state == .on + } + @objc func toggleLaunchAtLogin(_ sender: NSButton) { do { if sender.state == .on {