Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.9
-
None
Description
Modifier only shortcuts are shortcuts that are made of only modifier keys, for example Alt+Shift, etc. They have various use cases, e.g. push-to-talk, layout switching, etc.
Examples of modifier only shortcuts:
- Windows: Win to open the start menu, or Ctrl+Shift to switch between keyboard layouts
- Linux: in Plasma, every shortcut can contain either modifier keys or modifiers keys plus a normal key; user can also create their own shortcuts or reassign the keys of the existing shortcuts; in GNOME, Meta can be used to open the overview
- macOS: modifier only shortcuts aren't common on mac
- PTT: the Alt key is often used for push-to-talk (although it depends greatly on user preferences)
Normal shortcuts, e.g. Ctrl+A, are expected to be triggered on key press. Modifier only shortcuts are triggered depending on the context. For example, with push-to-talk, they are triggered on key press, but an application launcher may be triggered on key release (to avoid accidentally triggering when pressing a shortcut that starts with the same modifiers). The keys in a modifier only shortcut can be pressed in any order, e.g. Meta+Shift or Shift+Meta.
There are two issues with encoding and decoding modifier only shortcuts:
- QKeySequence::toString() will append a plus after the modifier keys, e.g. "Meta+Ctrl+"
- QKeySequence::fromString() fails to parse modifier only shortcuts
One potential workaround is to convert the last modifier key from Qt::KeyboardModifier to Qt::Key when constructing a QKeySequence object and then converting it back to Qt::KeyboardModifier when saving the QKeySequence to the disk, but it results in increased code complexity.
The expected behavior is:
- QKeySequence(Qt::MetaModifier + Qt::ControlModifier).toString() returns "Meta+Ctrl"
- QKeySequence::fromString("Meta+Ctrl") returns a QKeySequence object with Qt::MetaModifier and Qt::ControlModifier
- note that QKeySequence::fromString("Meta+Ctrl+") should still fail to parse
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-132435 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
613673,15 | QKeySequence: Add support for modifier only shortcuts | dev | qt/qtbase | Status: NEW | 0 | 0 |
617622,2 | QKeySequence: Refactor string parsing implementation | dev | qt/qtbase | Status: NEW | 0 | +1 |
621253,4 | tst_QShortcut: Test that modifier only shortcuts are not triggered | dev | qt/qtbase | Status: NEW | 0 | 0 |