summaryrefslogtreecommitdiff
path: root/qutebrowser
diff options
context:
space:
mode:
authorJimmy <jimmy@spalge.com>2021-10-03 16:44:30 +1300
committerJimmy <jimmy@spalge.com>2021-10-03 16:44:30 +1300
commitab447bd396b46247f6f12b8e2c697b0f7e01b95a (patch)
tree574250037fa3f0b24eb87bbb4870f0ed8a943cd5 /qutebrowser
parent84ed0da180690419de357feadd57aa9233bb60a0 (diff)
downloadqutebrowser-ab447bd396b46247f6f12b8e2c697b0f7e01b95a.tar.gz
qutebrowser-ab447bd396b46247f6f12b8e2c697b0f7e01b95a.zip
even more keypress related hacks
`QKeySequence.SequenceMatch` is one of the enums for which `Enum(0)` is no-longer falsey, compare to NoMatch instead. Otherwise the conditional is always false and forwarded keys don't work. Eg > from PyQt6.QtGui import QKeySequence, QKeyEvent > bool(QKeySequence.SequenceMatch.NoMatch) True > bool(QKeySequence.SequenceMatch(0)) True For `QKeySequence.SequenceMatch` and `QtCore.Qt.Key` and `QtCore.Qt.KeyboardModifier` int(enum_value) no longer works, eg > int(QtCore.Qt.KeyboardModifier(0)) TypeError: int() argument must be a string, a bytes-like object or a number, not 'KeyboardModifier'
Diffstat (limited to 'qutebrowser')
-rw-r--r--qutebrowser/keyinput/keyutils.py4
-rw-r--r--qutebrowser/keyinput/modeman.py4
2 files changed, 5 insertions, 3 deletions
diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py
index 7d043d556..db3fb2a0d 100644
--- a/qutebrowser/keyinput/keyutils.py
+++ b/qutebrowser/keyinput/keyutils.py
@@ -427,7 +427,7 @@ class KeyInfo:
def to_int(self) -> int:
"""Get the key as an integer (with key/modifiers)."""
- return int(self.key) | int(self.modifiers)
+ return self.key | self.modifiers.value
class KeySequence:
@@ -463,6 +463,8 @@ class KeySequence:
"""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()
def __str__(self) -> str:
diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py
index e59964432..53f7354c8 100644
--- a/qutebrowser/keyinput/modeman.py
+++ b/qutebrowser/keyinput/modeman.py
@@ -24,7 +24,7 @@ import dataclasses
from typing import Mapping, Callable, MutableMapping, Union, Set, cast
from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt, QObject, QEvent
-from PyQt6.QtGui import QKeyEvent
+from PyQt6.QtGui import QKeySequence, QKeyEvent
from qutebrowser.commands import runners
from qutebrowser.keyinput import modeparsers, basekeyparser
@@ -296,7 +296,7 @@ class ModeManager(QObject):
forward_unbound_keys = config.cache['input.forward_unbound_keys']
- if match:
+ if match != QKeySequence.SequenceMatch.NoMatch:
filter_this = True
elif (parser.passthrough or forward_unbound_keys == 'all' or
(forward_unbound_keys == 'auto' and is_non_alnum)):