From 622cfb481b977b0fbae4531e312cdfd222d1b558 Mon Sep 17 00:00:00 2001 From: shuntagami Date: Sun, 22 Mar 2026 17:58:34 +0900 Subject: [PATCH] Refactor force-capture into a dropdown option instead of a separate checkbox Replace the separate "Force capture standard volume and mute keys" checkbox with a new "Standard keys (force capture)" option in the existing Volume control dropdown (KeyboardVolume.mediaForce, tag=4). This integrates the feature more naturally into the existing UI, avoids removing the helpful "audio device name override" hint text, and eliminates the forceStandardVolumeMediaKeys preference key in favor of the enum-based approach. Co-Authored-By: Claude Opus 4.6 (1M context) --- MonitorControl/Enums/PrefKey.swift | 4 +--- .../Support/MediaKeyTapManager.swift | 6 +++--- MonitorControl/UI/Base.lproj/Main.storyboard | 20 +++++++++---------- MonitorControl/UI/en.lproj/Main.strings | 4 ++-- .../KeyboardPrefsViewController.swift | 17 +--------------- 5 files changed, 16 insertions(+), 35 deletions(-) diff --git a/MonitorControl/Enums/PrefKey.swift b/MonitorControl/Enums/PrefKey.swift index 39dbdf7..ce2eaaa 100644 --- a/MonitorControl/Enums/PrefKey.swift +++ b/MonitorControl/Enums/PrefKey.swift @@ -78,9 +78,6 @@ enum PrefKey: String { // Use fine OSD scale for volume case useFineScaleVolume - // Always capture standard volume media keys even when macOS output volume is controllable - case forceStandardVolumeMediaKeys - // Use smoothBrightness case disableSmoothBrightness @@ -215,4 +212,5 @@ enum KeyboardVolume: Int { case custom = 1 case both = 2 case disabled = 3 + case mediaForce = 4 } diff --git a/MonitorControl/Support/MediaKeyTapManager.swift b/MonitorControl/Support/MediaKeyTapManager.swift index df68108..5ebb97e 100644 --- a/MonitorControl/Support/MediaKeyTapManager.swift +++ b/MonitorControl/Support/MediaKeyTapManager.swift @@ -150,7 +150,7 @@ class MediaKeyTapManager: MediaKeyTapDelegate { if [KeyboardBrightness.media.rawValue, KeyboardBrightness.both.rawValue].contains(prefs.integer(forKey: PrefKey.keyboardBrightness.rawValue)) { keys.append(contentsOf: [.brightnessUp, .brightnessDown]) } - if [KeyboardVolume.media.rawValue, KeyboardVolume.both.rawValue].contains(prefs.integer(forKey: PrefKey.keyboardVolume.rawValue)) { + if [KeyboardVolume.media.rawValue, KeyboardVolume.both.rawValue, KeyboardVolume.mediaForce.rawValue].contains(prefs.integer(forKey: PrefKey.keyboardVolume.rawValue)) { keys.append(contentsOf: [.mute, .volumeUp, .volumeDown]) } // Remove brightness keys if no external displays are connected, but only if brightness fine control is not active @@ -166,8 +166,8 @@ class MediaKeyTapManager: MediaKeyTapDelegate { let keysToDelete: [MediaKey] = [.brightnessUp, .brightnessDown] keys.removeAll { keysToDelete.contains($0) } } - // Remove volume related keys if audio device is controllable unless the user opted into force-capturing them. - if !prefs.bool(forKey: PrefKey.forceStandardVolumeMediaKeys.rawValue), let defaultAudioDevice = app.coreAudio.defaultOutputDevice { + // Remove volume related keys if audio device is controllable (skip when user chose force-capture mode) + if prefs.integer(forKey: PrefKey.keyboardVolume.rawValue) != KeyboardVolume.mediaForce.rawValue, let defaultAudioDevice = app.coreAudio.defaultOutputDevice { let keysToDelete: [MediaKey] = [.volumeUp, .volumeDown, .mute] if prefs.integer(forKey: PrefKey.multiKeyboardVolume.rawValue) == MultiKeyboardVolume.audioDeviceNameMatching.rawValue { if DisplayManager.shared.updateAudioControlTargetDisplays(deviceName: defaultAudioDevice.name) == 0 { diff --git a/MonitorControl/UI/Base.lproj/Main.storyboard b/MonitorControl/UI/Base.lproj/Main.storyboard index 6d215ca..d0398a7 100644 --- a/MonitorControl/UI/Base.lproj/Main.storyboard +++ b/MonitorControl/UI/Base.lproj/Main.storyboard @@ -1004,6 +1004,7 @@ + @@ -1129,16 +1130,14 @@ - + + + + + + + + @@ -1182,7 +1181,6 @@ - diff --git a/MonitorControl/UI/en.lproj/Main.strings b/MonitorControl/UI/en.lproj/Main.strings index 01d83d5..41aa602 100644 --- a/MonitorControl/UI/en.lproj/Main.strings +++ b/MonitorControl/UI/en.lproj/Main.strings @@ -415,8 +415,8 @@ /* Class = "NSButtonCell"; title = "Show percentages"; ObjectID = "ZUu-MR-XwA"; */ "ZUu-MR-XwA.title" = "Show percentages"; -/* Class = "NSButtonCell"; title = "Force capture standard volume and mute keys"; ObjectID = "5V3-gQ-jWm"; */ -"5V3-gQ-jWm.title" = "Force capture standard volume and mute keys"; +/* Class = "NSMenuItem"; title = "Standard keys (force capture)"; ObjectID = "fVk-mR-9Xp"; */ +"fVk-mR-9Xp.title" = "Standard keys (force capture)"; /* Class = "NSTextFieldCell"; title = "Combined dimming switchover point:"; ObjectID = "zv8-pZ-OPy"; */ "zv8-pZ-OPy.title" = "Combined dimming switchover point:"; diff --git a/MonitorControl/View Controllers/Preferences/KeyboardPrefsViewController.swift b/MonitorControl/View Controllers/Preferences/KeyboardPrefsViewController.swift index 8124e2a..8bccf3a 100644 --- a/MonitorControl/View Controllers/Preferences/KeyboardPrefsViewController.swift +++ b/MonitorControl/View Controllers/Preferences/KeyboardPrefsViewController.swift @@ -33,7 +33,6 @@ class KeyboardPrefsViewController: NSViewController, SettingsPane { @IBOutlet var multiKeyboardVolume: NSPopUpButton! @IBOutlet var useFineScale: NSButton! @IBOutlet var useFineScaleVolume: NSButton! - @IBOutlet var forceStandardVolumeMediaKeys: NSButton! @IBOutlet var separateCombinedScale: NSButton! @IBOutlet var rowKeyboardBrightnessPopUp: NSGridRow! @@ -93,11 +92,9 @@ class KeyboardPrefsViewController: NSViewController, SettingsPane { if self.keyboardVolume.selectedTag() == KeyboardVolume.disabled.rawValue { self.multiKeyboardVolume.isEnabled = false self.useFineScaleVolume.isEnabled = false - self.forceStandardVolumeMediaKeys.isEnabled = false } else { self.multiKeyboardVolume.isEnabled = true self.useFineScaleVolume.isEnabled = true - self.forceStandardVolumeMediaKeys.isEnabled = true } if self.multiKeyboardBrightness.selectedTag() == MultiKeyboardBrightness.focusInsteadOfMouse.rawValue { @@ -112,7 +109,7 @@ class KeyboardPrefsViewController: NSViewController, SettingsPane { self.rowUseAudioNameText.isHidden = false self.rowUseAudioMouseText.isHidden = true } else { - self.rowUseAudioNameText.isHidden = false + self.rowUseAudioNameText.isHidden = true self.rowUseAudioMouseText.isHidden = false } } @@ -155,7 +152,6 @@ class KeyboardPrefsViewController: NSViewController, SettingsPane { self.multiKeyboardVolume.selectItem(withTag: prefs.integer(forKey: PrefKey.multiKeyboardVolume.rawValue)) self.useFineScale.state = prefs.bool(forKey: PrefKey.useFineScaleBrightness.rawValue) ? .on : .off self.useFineScaleVolume.state = prefs.bool(forKey: PrefKey.useFineScaleVolume.rawValue) ? .on : .off - self.forceStandardVolumeMediaKeys.state = prefs.bool(forKey: PrefKey.forceStandardVolumeMediaKeys.rawValue) ? .on : .off self.separateCombinedScale.state = prefs.bool(forKey: PrefKey.separateCombinedScale.rawValue) ? .on : .off self.updateGridLayout() } @@ -193,17 +189,6 @@ class KeyboardPrefsViewController: NSViewController, SettingsPane { } } - @IBAction func forceStandardVolumeMediaKeysClicked(_ sender: NSButton) { - switch sender.state { - case .on: - prefs.set(true, forKey: PrefKey.forceStandardVolumeMediaKeys.rawValue) - case .off: - prefs.set(false, forKey: PrefKey.forceStandardVolumeMediaKeys.rawValue) - default: break - } - app.updateMediaKeyTap() - } - @IBAction func separateCombinedScale(_ sender: NSButton) { switch sender.state { case .on: