diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py index 5402bce77..f2b87eea6 100644 --- a/qutebrowser/keyinput/basekeyparser.py +++ b/qutebrowser/keyinput/basekeyparser.py @@ -67,9 +67,13 @@ class BaseKeyParser(QObject): Signals: keystring_updated: Emitted when the keystring is updated. arg: New keystring. + request_leave: Emitted to request leaving a mode. + arg 0: Mode to leave. + arg 1: Reason for leaving. """ keystring_updated = pyqtSignal(str) + request_leave = pyqtSignal(usertypes.KeyMode, str) do_log = True passthrough = False diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index 11156e4e4..3a352ba19 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -225,6 +225,7 @@ class ModeManager(QObject): assert isinstance(mode, usertypes.KeyMode) assert parser is not None self._parsers[mode] = parser + parser.request_leave.connect(self.leave) def enter(self, mode, reason=None, only_if_normal=False): """Enter a new mode. diff --git a/qutebrowser/keyinput/modeparsers.py b/qutebrowser/keyinput/modeparsers.py index 745c848e4..dd7ec8b6a 100644 --- a/qutebrowser/keyinput/modeparsers.py +++ b/qutebrowser/keyinput/modeparsers.py @@ -27,7 +27,7 @@ from PyQt5.QtCore import pyqtSlot, Qt from qutebrowser.utils import message from qutebrowser.config import config -from qutebrowser.keyinput import keyparser, modeman +from qutebrowser.keyinput import keyparser from qutebrowser.utils import usertypes, log, objreg, utils @@ -276,6 +276,6 @@ class MarkKeyParser(keyparser.BaseKeyParser): else: raise ValueError("{} is not a valid mark mode".format(self._mode)) - modeman.leave(self._win_id, self._mode, "valid mark key") + self.request_leave.emit(self._mode, "valid mark key") return True