make the Upgrade All confirmation dialog optional, on by default

New "Ask for confirmation before Upgrade All" checkbox; when disabled,
Upgrade All runs immediately. Auto-upgrade is unaffected either way —
it never prompts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
maxsoch 2026-07-06 22:09:26 +02:00
parent 29b9412a34
commit 0bc18b79b8
2 changed files with 16 additions and 1 deletions

View file

@ -210,7 +210,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
} }
@objc func upgradeAll() { @objc func upgradeAll() {
guard confirmUpgrade() else { return } if Settings.confirmBeforeUpgradeAll {
guard confirmUpgrade() else { return }
}
statusMenuItem.title = "Upgrading..." statusMenuItem.title = "Upgrading..."

View file

@ -21,6 +21,7 @@ class SettingsWindowController: NSWindowController {
var autoUpgradeCasksCheckbox: NSButton! var autoUpgradeCasksCheckbox: NSButton!
var notifyCheckbox: NSButton! var notifyCheckbox: NSButton!
var showCountCheckbox: NSButton! var showCountCheckbox: NSButton!
var confirmCheckbox: NSButton!
convenience init(appDelegate: AppDelegate) { convenience init(appDelegate: AppDelegate) {
let window = NSWindow( let window = NSWindow(
@ -123,6 +124,12 @@ class SettingsWindowController: NSWindowController {
action: #selector(toggleShowCount(_:)) action: #selector(toggleShowCount(_:))
) )
confirmCheckbox = NSButton(
checkboxWithTitle: "Ask for confirmation before Upgrade All",
target: self,
action: #selector(toggleConfirm(_:))
)
let stack = NSStackView(views: [ let stack = NSStackView(views: [
frequencyRow, frequencyRow,
customRow, customRow,
@ -134,6 +141,7 @@ class SettingsWindowController: NSWindowController {
separator(), separator(),
notifyCheckbox, notifyCheckbox,
showCountCheckbox, showCountCheckbox,
confirmCheckbox,
launchAtLoginCheckbox, launchAtLoginCheckbox,
]) ])
stack.orientation = .vertical stack.orientation = .vertical
@ -174,6 +182,7 @@ class SettingsWindowController: NSWindowController {
autoUpgradeCasksCheckbox.state = Settings.autoUpgradeCasks ? .on : .off autoUpgradeCasksCheckbox.state = Settings.autoUpgradeCasks ? .on : .off
notifyCheckbox.state = Settings.notifyOnNewUpdates ? .on : .off notifyCheckbox.state = Settings.notifyOnNewUpdates ? .on : .off
showCountCheckbox.state = Settings.showCountInMenuBar ? .on : .off showCountCheckbox.state = Settings.showCountInMenuBar ? .on : .off
confirmCheckbox.state = Settings.confirmBeforeUpgradeAll ? .on : .off
} }
func separator() -> NSBox { func separator() -> NSBox {
@ -239,6 +248,10 @@ class SettingsWindowController: NSWindowController {
appDelegate?.updateMenuBarCount() // reflect immediately, no refetch needed appDelegate?.updateMenuBarCount() // reflect immediately, no refetch needed
} }
@objc func toggleConfirm(_ sender: NSButton) {
Settings.confirmBeforeUpgradeAll = sender.state == .on
}
@objc func toggleLaunchAtLogin(_ sender: NSButton) { @objc func toggleLaunchAtLogin(_ sender: NSButton) {
do { do {
if sender.state == .on { if sender.state == .on {