summaryrefslogtreecommitdiff
path: root/qutebrowser
diff options
context:
space:
mode:
authorJimmy <jimmy@spalge.com>2021-11-13 15:16:29 +1300
committerJimmy <jimmy@spalge.com>2021-11-13 15:52:46 +1300
commit2c00058a8367930fae7349ebdada981753ad45db (patch)
treedd557dfad9d7bea3635ae46da859dc7bb6ad2125 /qutebrowser
parent864810a55981a8471d1295ab82ce144a7b09c01a (diff)
downloadqutebrowser-2c00058a8367930fae7349ebdada981753ad45db.tar.gz
qutebrowser-2c00058a8367930fae7349ebdada981753ad45db.zip
fix matching bindings with modifiers
Doing `Qt.Key | Qt.KeyboardModifier` now results in a QKeyCombination. append_event() always does that (even if the modifier is NoModifier). Previous hacks round this area: e61597ca817e369c95 (initial keyhack, partially corrected in this commit) 1cc87d4d47bc15754d (initial QKeyCombination introduction) ab447bd396b46247f6 (Earlier attempt at a fix, mostly corrected in this commit)
Diffstat (limited to 'qutebrowser')
-rw-r--r--qutebrowser/keyinput/keyutils.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py
index db3fb2a0d..8dba28424 100644
--- a/qutebrowser/keyinput/keyutils.py
+++ b/qutebrowser/keyinput/keyutils.py
@@ -150,13 +150,13 @@ _SPECIAL_NAMES = {
def _assert_plain_key(key: Qt.Key) -> None:
"""Make sure this is a key without KeyboardModifiers mixed in."""
- #assert not key & Qt.KeyboardModifier.KeyboardModifierMask, hex(key)
+ assert not key.value & Qt.KeyboardModifier.KeyboardModifierMask.value, hex(key)
def _assert_plain_modifier(key: _ModifierType) -> None:
"""Make sure this is a modifier without a key mixed in."""
- #mask = Qt.KeyboardModifier.KeyboardModifierMask
- #assert not key & ~mask, hex(key) # type: ignore[operator]
+ mask = Qt.KeyboardModifier.KeyboardModifierMask
+ assert not key & ~mask, hex(key) # type: ignore[operator]
def _is_printable(key: Qt.Key) -> bool:
@@ -425,9 +425,9 @@ class KeyInfo:
"""Get a QKeyEvent from this KeyInfo."""
return QKeyEvent(typ, self.key, self.modifiers, self.text())
- def to_int(self) -> int:
+ def to_int(self) -> QKeyCombination:
"""Get the key as an integer (with key/modifiers)."""
- return self.key | self.modifiers.value
+ return self.key | self.modifiers
class KeySequence:
@@ -461,11 +461,8 @@ class KeySequence:
def _convert_key(self, key: Union[int, Qt.KeyboardModifier]) -> int:
"""Convert a single key for QKeySequence."""
- #assert isinstance(key, (int, Qt.KeyboardModifier)), key
- #return int(key)
- if isinstance(key, int):
- return key
- return key.key()
+ assert isinstance(key, QKeyCombination), key
+ return key.toCombined()
def __str__(self) -> str:
parts = []