WIP: Enter key confirms branch checkout#110
Conversation
When switching branches, enter key automatically comfirms dialog. WIP questions: - Should it be ctrl+enter? - Should enter confirm, unless user interacts with dialog options?
|
I agree that the Return key should always accept the current dialog, and it does on KDE. If it doesn't, that's a Qt integration quirk and this behavior varies from DE to DE. I thought we'd fixed this for non-KDE environments, though. See installDialogReturnShortcut which is called from here. What's your desktop environment? |
|
I'm using Cinnamon desktop, which seems to be quite quirky I'm discovering. If it works on KDE and Gnome, probably leave it at that. I'll review and see what I find 👍 |
|
I tried a VM with Linux Mint 22.3 (Cinnamon), and the Return key seems to work out of the box in CheckoutDialog. I tried both the Flatpak and running from source with PyQt6 6.11. If you can figure out why |
|
Was just going to post that the main return key works fine, but the numeric keypad enter key does not. QT treats them as distinct keys (as it should), so it's a very small patch to fix. However writing reliable unit tests is a little tricky. I'll post what I have tomorrow for review. |
|
Oh, that makes sense. I'm partial to tenkeyless keyboards, so I never noticed that Key_Enter didn't work on GNOME/Cinnamon 🤓 Yeah, testing this might be tricky because the offscreen testing environment is standardized and it doesn't inherit any quirks from the host DE. And as it happens, Key_Enter already works out of the box in the offscreen environment. For example, in # checkoutDialog.accept() -- commented out
checkoutDialog.ui.detachHeadRadioButton.setFocus() # set focus on radio button to trigger GNOME/Cinnamon quirk before hitting Enter
waitUntilTrue(checkoutDialog.ui.detachHeadRadioButton.hasFocus)
QTest.keyPress(checkoutDialog.ui.detachHeadRadioButton, Qt.Key.Key_Enter)tl;dr: I think it's fine if we don't test Key_Enter specifically. |
The problem
When I double click a commit/branch in the commit graph, I want to be able to quickly just reach over to the enter key and confirm the switch. Right now, the enter key doesn't confirm the dialog.
The change
In the "Check out commit" dialog, Return/Enter should accept the default action (e.g. "Switch Branch") instead of toggling the focused radio button.
CheckoutCommitDialognow marks the OK button as default and installs dialog-level shortcuts that click OK when it is enabled.Note: I kept the commit tagged with WIP to discuss a bit before it's merged.
Questions: