feat: replace ShortcutRecorder with MASShortcut#233
Merged
Conversation
Replace the ShortcutRecorder SPM dependency and custom GlobalHotkeys/Hotkey ObjC classes with MASShortcut, which provides both the recorder UI (MASShortcutView) and global hotkey monitoring (MASShortcutBinder). This simplifies the architecture from three layers to two: - UI: NSViewRepresentable wrapping MASShortcutView with UserDefaults binding - Runtime: MASShortcutBinder binds defaults keys to notification-posting actions MASDictionaryTransformer ensures backward-compatible reading/writing of the existing UserDefaults plist format, so no user data migration is needed. Changes: - Add MASShortcut SPM dependency (branch master), remove ShortcutRecorder - Create GlobalShortcuts.swift for hotkey binding via MASShortcutBinder - Rewrite ShortcutRecorderView.swift to wrap MASShortcutView (73 → 20 lines) - Wire GlobalShortcuts.shared into ApplicationController launch - Remove GlobalHotkeys NSCustomObject from MainMenu.xib - Delete GlobalHotkeys.h/.m and Hotkey.h/.m - Use bridged Preferences.h constants in HotkeysTab
Cover the MASShortcut integration with unit tests: GlobalShortcutsTests: - Singleton identity and non-nil - MASShortcutBinder configured with MASDictionaryTransformerName - Each hotkey binding registers with the shortcut monitor ShortcutRecorderViewTests: - Preferences.h constants match expected string values - MASShortcutView configured with correct key, style, and transformer - View reads shortcut from UserDefaults via dictionary transformer - Clearing shortcut writes empty dictionary (MASShortcut behavior)
- Remove unused expectedNotificationName parameter from test helper and rename methods to reflect what they actually verify (registration) - Fix stale doc comment referencing deleted GlobalHotkeys class - Pin MASShortcut to specific revision instead of branch master
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace ShortcutRecorder with MASShortcut, which provides both the recorder UI and global hotkey monitoring in a single library. Based on the approach from #220.
GlobalHotkeys.h/.mandHotkey.h/.m(394 lines removed)MASDictionaryTransformerreads/writes the same UserDefaults plist formatTest plan
./build.sh)