Pass broken keychains to browser in passthrough modes
This commit is contained in:
parent
ee13dac738
commit
496e7043ef
|
|
@ -132,7 +132,85 @@ class NormalKeyParser(CommandKeyParser):
|
|||
self._inhibited = False
|
||||
|
||||
|
||||
class HintKeyParser(basekeyparser.BaseKeyParser):
|
||||
|
||||
class PassthroughKeyParser(CommandKeyParser):
|
||||
|
||||
"""KeyChainParser which passes through normal keys.
|
||||
|
||||
Used for insert/passthrough modes.
|
||||
|
||||
Attributes:
|
||||
_mode: The mode this keyparser is for.
|
||||
_ignore_next_key: Whether to pass the next key through.
|
||||
"""
|
||||
|
||||
do_log = False
|
||||
passthrough = True
|
||||
|
||||
def __init__(self, win_id, mode, parent=None):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
mode: The mode this keyparser is for.
|
||||
parent: Qt parent.
|
||||
warn: Whether to warn if an ignored key was bound.
|
||||
"""
|
||||
super().__init__(win_id, parent)
|
||||
self._read_config(mode)
|
||||
self._mode = mode
|
||||
self._ignore_next_key = False
|
||||
|
||||
def __repr__(self):
|
||||
return utils.get_repr(self, mode=self._mode)
|
||||
|
||||
def handle(self, e, *, dry_run=False):
|
||||
"""Override to pass the chain through on NoMatch.
|
||||
|
||||
Args:
|
||||
e: the KeyPressEvent from Qt.
|
||||
dry_run: Don't actually execute anything, only check whether there
|
||||
would be a match.
|
||||
|
||||
Return:
|
||||
A self.Match member.
|
||||
"""
|
||||
if keyutils.is_modifier_key(e.key()) or self._ignore_next_key:
|
||||
self._ignore_next_key = self._ignore_next_key and dry_run
|
||||
return QKeySequence.NoMatch
|
||||
|
||||
sequence = self._sequence
|
||||
match = super().handle(e, dry_run=dry_run)
|
||||
|
||||
if dry_run or len(sequence) == 0 or match != QKeySequence.NoMatch:
|
||||
return match
|
||||
|
||||
window = QApplication.focusWindow()
|
||||
if window is None:
|
||||
return match
|
||||
|
||||
self._ignore_next_key = True
|
||||
for keyinfo in sequence.append_event(e):
|
||||
press_event = keyinfo.to_event(QEvent.KeyPress)
|
||||
release_event = keyinfo.to_event(QEvent.KeyRelease)
|
||||
QApplication.postEvent(window, press_event)
|
||||
QApplication.postEvent(window, release_event)
|
||||
|
||||
return QKeySequence.ExactMatch
|
||||
|
||||
|
||||
class PromptKeyParser(CommandKeyParser):
|
||||
|
||||
"""KeyParser for yes/no prompts."""
|
||||
|
||||
def __init__(self, win_id, parent=None):
|
||||
super().__init__(win_id, parent, supports_count=False)
|
||||
self._read_config('yesno')
|
||||
|
||||
def __repr__(self):
|
||||
return utils.get_repr(self)
|
||||
|
||||
|
||||
class HintKeyParser(CommandKeyParser):
|
||||
|
||||
"""KeyChainParser for hints.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue