Skip to content

WIP: Enter key confirms branch checkout#110

Open
stdout-se wants to merge 1 commit into
jorio:masterfrom
stdout-se:wip/branch-switch
Open

WIP: Enter key confirms branch checkout#110
stdout-se wants to merge 1 commit into
jorio:masterfrom
stdout-se:wip/branch-switch

Conversation

@stdout-se

Copy link
Copy Markdown
Contributor

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.

image

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.

CheckoutCommitDialog now 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:

  • Should it be ctrl+enter instead? I think enter still makes sense?
  • Should enter confirm, unless user interacts with dialog options? I think there are some differences between how different desktop environments handle this, it seems to be different between mac, windows, and even different linux desktops...

When switching branches, enter key automatically comfirms dialog.

WIP questions:
- Should it be ctrl+enter?
- Should enter confirm, unless user interacts with dialog options?
@jorio

jorio commented Jun 2, 2026

Copy link
Copy Markdown
Owner

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?

@stdout-se

Copy link
Copy Markdown
Contributor Author

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 👍

@jorio

jorio commented Jun 3, 2026

Copy link
Copy Markdown
Owner

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 installDialogReturnShortcut has no effect on your setup, please let me know.

@stdout-se

Copy link
Copy Markdown
Contributor Author

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.

@jorio

jorio commented Jun 3, 2026

Copy link
Copy Markdown
Owner

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 testCheckoutCommitDetachHead, replacing checkoutDialog.accept() with this snippet will work in offscreen mode, but not in visual mode in GNOME/Cinnamon:

        # 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants