Fix hotkey triggering logic for subset combinations and exact matching #8
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.
This PR includes two important improvements to the hotkey handling system:
Priority-based processing: Hotkeys with more keys are processed first.
For example, if both Cmd+C and Cmd+Shift+C are registered, pressing
Cmd+Shift+C will only trigger the action registered for Cmd+Shift+C.
Exact matching: The number of pressed keys must exactly match the number
of registered keys for an action to be executed. This prevents unregistered
combinations (e.g., Cmd+Alt+Shift+A) from accidentally triggering
other actions.
Additionally, this PR adds a comprehensive test suite covering various hotkey scenarios:
These tests validate the improved behavior and ensure future changes won't break
these important use cases. The changes make qHotKeys behavior more predictable and intuitive,
better aligning with standard shortcut behavior in operating systems and applications.