Show passthrough modes in statusbar

This commit is contained in:
Florian Bruhin 2014-04-24 06:59:39 +02:00
parent afa9c47867
commit 95691e1e11
3 changed files with 19 additions and 5 deletions

View File

@ -255,6 +255,8 @@ class QuteBrowser(QApplication):
tabs.currentChanged.connect(self.mainwindow.update_inspector)
# status bar
modemanager.manager.entered.connect(status.on_mode_entered)
modemanager.manager.leaved.connect(status.on_mode_left)
# FIXME what to do here?
tabs.keypress.connect(status.keypress)
for obj in [kp["normal"], tabs]:

View File

@ -57,11 +57,11 @@ class ModeManager(QObject):
"""Manager for keyboard modes.
Attributes:
mode: The current mode (readonly property).
passthrough: A list of modes in which to pass through events.
_handlers: A dictionary of modes and their handlers.
_passthrough: A list of modes in which to pass through events.
_mode_stack: A list of the modes we're currently in, with the active
one on the right.
mode: The current mode (readonly property).
Signals:
entered: Emitted when a mode is entered.
@ -76,7 +76,7 @@ class ModeManager(QObject):
def __init__(self, parent=None):
super().__init__(parent)
self._handlers = {}
self._passthrough = []
self.passthrough = []
self._mode_stack = []
@property
@ -97,7 +97,7 @@ class ModeManager(QObject):
"""
self._handlers[mode] = handler
if passthrough:
self._passthrough.append(mode)
self.passthrough.append(mode)
def enter(self, mode):
"""Enter a new mode.
@ -140,7 +140,7 @@ class ModeManager(QObject):
if typ not in [QEvent.KeyPress, QEvent.KeyRelease]:
# We're not interested in non-key-events so we pass them through.
return False
elif self.mode in self._passthrough:
elif self.mode in self.passthrough:
# We're currently in a passthrough mode so we pass everything
# through.*and* let the passthrough keyhandler know.
# FIXME what if we leave the passthrough mode right here?

View File

@ -170,6 +170,18 @@ class StatusBar(QWidget):
self.txt.set_temptext('')
self.clear_error()
@pyqtSlot(str)
def on_mode_entered(self, mode):
"""Mark certain modes in the commandline."""
if mode in modemanager.manager.passthrough:
self.txt.normaltext = "-- {} MODE --".format(mode.upper())
@pyqtSlot(str)
def on_mode_left(self, mode):
"""Clear marked mode."""
if mode in modemanager.manager.passthrough:
self.txt.normaltext = ""
def resizeEvent(self, e):
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.