feat(ui): hide-to-tray Cmd-W / Cmd-M / Esc shortcuts on main window#167
Open
hughesyadaddy wants to merge 2 commits into
Open
feat(ui): hide-to-tray Cmd-W / Cmd-M / Esc shortcuts on main window#167hughesyadaddy wants to merge 2 commits into
hughesyadaddy wants to merge 2 commits into
Conversation
3bd506c to
18b097b
Compare
Mouser is configured as LSUIElement on macOS, so closing the main window must keep the engine running. The existing onClosing handler covered the red traffic light, but Cmd-W, Cmd-M, and Esc never reached it because LSUIElement apps don't ship a platform menu bar for Qt to bind StandardKey.Close against. Route all four dismissal paths through a single dismiss() helper and add explicit Shortcut blocks for Cmd-W (StandardKey.Close), Cmd-M (Ctrl+M), and Esc. Cmd-W and Cmd-M use Qt.ApplicationShortcut; Esc uses Qt.WindowShortcut so it stays scoped to the focused main window. Modal dialogs continue to consume Esc first via their Popup.CloseOnEscape policy.
- Make dismiss() idempotent when the window is already hidden so QApplication doesn't process a redundant hide() / visibilityChanged round-trip. - Gate the three Shortcut bindings on root.visible so Cmd-W / Cmd-M never fire from background after the user has already tucked the window into the tray. - Update comments to make the cross-platform contract explicit and document that modal Popups consume Esc via CloseOnEscape before the window shortcut has a chance to hide the main window.
77c1168 to
19938c8
Compare
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.
Why
Mouser ships with
start_minimizeddefaulting totrue, and thefeat/macos-app-shellwork turns it into a proper menu-bar app onmacOS. That's the right model — but the moment the main window is
open, the standard keyboard shortcuts users expect from menu-bar apps
do not work:
it'll hide the window the way every other macOS menu-bar app
behaves and end up quitting the app or hunting for the dock icon.
the hood, leaving the tray icon orphaned.
even though the app is happy to live in the tray.
All three keystrokes already have a sensible target: route them
through the same
dismiss()path the tray icon's "Hide" item uses.What changed
ui/qml/Main.qml:dismiss()function consolidates the existing close paths(tray "Hide", window close button, etc).
Shortcutblocks bind Cmd-W (StandardKey.Close),Cmd-M (
Ctrl+M), and Esc todismiss().Shortcut.WindowShortcutscope is used so the bindings only firewhile the main window is the active key window — they don't
steal Cmd-W from any modal dialog that's open over the window.
Escshortcut is gated on!anyDialogOpenso it doesn'tconflict with
Popup.CloseOnEscape(which dismisses the popupfirst).
No behaviour change for users who don't press these keys, no new
config, no new strings.
Test plan
device-list dialog open → dialog closes, window stays.
pytest tests/green.