From 274f2a9d199684120ec0c66e805410a3a920fb46 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 5 Mar 2018 06:36:01 +0100 Subject: [PATCH] Rename eventFilter methods in modeman --- qutebrowser/app.py | 2 +- qutebrowser/keyinput/modeman.py | 12 ++++++------ tests/unit/keyinput/test_modeman.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 2794d36e2..73b5557cc 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -900,7 +900,7 @@ class EventFilter(QObject): return False try: man = objreg.get('mode-manager', scope='window', window='current') - return man.eventFilter(event) + return man.handle_event(event) except objreg.RegistryUnavailableError: # No window available yet, or not a MainWindow return False diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index 8d2830cc1..168efde5b 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -143,7 +143,7 @@ class ModeManager(QObject): def __repr__(self): return utils.get_repr(self, mode=self.mode) - def _eventFilter_keypress(self, event, *, dry_run=False): + def _handle_keypress(self, event, *, dry_run=False): """Handle filtering of KeyPress events. Args: @@ -187,7 +187,7 @@ class ModeManager(QObject): filter_this, focus_widget)) return filter_this - def _eventFilter_keyrelease(self, event): + def _handle_keyrelease(self, event): """Handle filtering of KeyRelease events. Args: @@ -303,7 +303,7 @@ class ModeManager(QObject): raise ValueError("Can't leave normal mode!") self.leave(self.mode, 'leave current') - def eventFilter(self, event): + def handle_event(self, event): """Filter all events based on the currently set mode. Also calls the real keypress handler. @@ -319,10 +319,10 @@ class ModeManager(QObject): return False handlers = { - QEvent.KeyPress: self._eventFilter_keypress, - QEvent.KeyRelease: self._eventFilter_keyrelease, + QEvent.KeyPress: self._handle_keypress, + QEvent.KeyRelease: self._handle_keyrelease, QEvent.ShortcutOverride: - functools.partial(self._eventFilter_keypress, dry_run=True), + functools.partial(self._handle_keypress, dry_run=True), } handler = handlers[event.type()] return handler(event) diff --git a/tests/unit/keyinput/test_modeman.py b/tests/unit/keyinput/test_modeman.py index de9671961..d94d7d38b 100644 --- a/tests/unit/keyinput/test_modeman.py +++ b/tests/unit/keyinput/test_modeman.py @@ -54,4 +54,4 @@ def modeman(mode_manager): def test_non_alphanumeric(key, modifiers, filtered, fake_keyevent, modeman): """Make sure non-alphanumeric keys are passed through correctly.""" evt = fake_keyevent(key=key, modifiers=modifiers) - assert modeman.eventFilter(evt) == filtered + assert modeman.handle_event(evt) == filtered