Rename eventFilter methods in modeman

This commit is contained in:
Florian Bruhin 2018-03-05 06:36:01 +01:00
parent e01db79ce9
commit 274f2a9d19
3 changed files with 8 additions and 8 deletions

View File

@ -900,7 +900,7 @@ class EventFilter(QObject):
return False return False
try: try:
man = objreg.get('mode-manager', scope='window', window='current') man = objreg.get('mode-manager', scope='window', window='current')
return man.eventFilter(event) return man.handle_event(event)
except objreg.RegistryUnavailableError: except objreg.RegistryUnavailableError:
# No window available yet, or not a MainWindow # No window available yet, or not a MainWindow
return False return False

View File

@ -143,7 +143,7 @@ class ModeManager(QObject):
def __repr__(self): def __repr__(self):
return utils.get_repr(self, mode=self.mode) 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. """Handle filtering of KeyPress events.
Args: Args:
@ -187,7 +187,7 @@ class ModeManager(QObject):
filter_this, focus_widget)) filter_this, focus_widget))
return filter_this return filter_this
def _eventFilter_keyrelease(self, event): def _handle_keyrelease(self, event):
"""Handle filtering of KeyRelease events. """Handle filtering of KeyRelease events.
Args: Args:
@ -303,7 +303,7 @@ class ModeManager(QObject):
raise ValueError("Can't leave normal mode!") raise ValueError("Can't leave normal mode!")
self.leave(self.mode, 'leave current') self.leave(self.mode, 'leave current')
def eventFilter(self, event): def handle_event(self, event):
"""Filter all events based on the currently set mode. """Filter all events based on the currently set mode.
Also calls the real keypress handler. Also calls the real keypress handler.
@ -319,10 +319,10 @@ class ModeManager(QObject):
return False return False
handlers = { handlers = {
QEvent.KeyPress: self._eventFilter_keypress, QEvent.KeyPress: self._handle_keypress,
QEvent.KeyRelease: self._eventFilter_keyrelease, QEvent.KeyRelease: self._handle_keyrelease,
QEvent.ShortcutOverride: QEvent.ShortcutOverride:
functools.partial(self._eventFilter_keypress, dry_run=True), functools.partial(self._handle_keypress, dry_run=True),
} }
handler = handlers[event.type()] handler = handlers[event.type()]
return handler(event) return handler(event)

View File

@ -54,4 +54,4 @@ def modeman(mode_manager):
def test_non_alphanumeric(key, modifiers, filtered, fake_keyevent, modeman): def test_non_alphanumeric(key, modifiers, filtered, fake_keyevent, modeman):
"""Make sure non-alphanumeric keys are passed through correctly.""" """Make sure non-alphanumeric keys are passed through correctly."""
evt = fake_keyevent(key=key, modifiers=modifiers) evt = fake_keyevent(key=key, modifiers=modifiers)
assert modeman.eventFilter(evt) == filtered assert modeman.handle_event(evt) == filtered