Show passthrough modes in statusbar
This commit is contained in:
parent
afa9c47867
commit
95691e1e11
@ -255,6 +255,8 @@ class QuteBrowser(QApplication):
|
|||||||
tabs.currentChanged.connect(self.mainwindow.update_inspector)
|
tabs.currentChanged.connect(self.mainwindow.update_inspector)
|
||||||
|
|
||||||
# status bar
|
# status bar
|
||||||
|
modemanager.manager.entered.connect(status.on_mode_entered)
|
||||||
|
modemanager.manager.leaved.connect(status.on_mode_left)
|
||||||
# FIXME what to do here?
|
# FIXME what to do here?
|
||||||
tabs.keypress.connect(status.keypress)
|
tabs.keypress.connect(status.keypress)
|
||||||
for obj in [kp["normal"], tabs]:
|
for obj in [kp["normal"], tabs]:
|
||||||
|
@ -57,11 +57,11 @@ class ModeManager(QObject):
|
|||||||
"""Manager for keyboard modes.
|
"""Manager for keyboard modes.
|
||||||
|
|
||||||
Attributes:
|
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.
|
_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
|
_mode_stack: A list of the modes we're currently in, with the active
|
||||||
one on the right.
|
one on the right.
|
||||||
mode: The current mode (readonly property).
|
|
||||||
|
|
||||||
Signals:
|
Signals:
|
||||||
entered: Emitted when a mode is entered.
|
entered: Emitted when a mode is entered.
|
||||||
@ -76,7 +76,7 @@ class ModeManager(QObject):
|
|||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._handlers = {}
|
self._handlers = {}
|
||||||
self._passthrough = []
|
self.passthrough = []
|
||||||
self._mode_stack = []
|
self._mode_stack = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -97,7 +97,7 @@ class ModeManager(QObject):
|
|||||||
"""
|
"""
|
||||||
self._handlers[mode] = handler
|
self._handlers[mode] = handler
|
||||||
if passthrough:
|
if passthrough:
|
||||||
self._passthrough.append(mode)
|
self.passthrough.append(mode)
|
||||||
|
|
||||||
def enter(self, mode):
|
def enter(self, mode):
|
||||||
"""Enter a new mode.
|
"""Enter a new mode.
|
||||||
@ -140,7 +140,7 @@ class ModeManager(QObject):
|
|||||||
if typ not in [QEvent.KeyPress, QEvent.KeyRelease]:
|
if typ not in [QEvent.KeyPress, QEvent.KeyRelease]:
|
||||||
# We're not interested in non-key-events so we pass them through.
|
# We're not interested in non-key-events so we pass them through.
|
||||||
return False
|
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
|
# We're currently in a passthrough mode so we pass everything
|
||||||
# through.*and* let the passthrough keyhandler know.
|
# through.*and* let the passthrough keyhandler know.
|
||||||
# FIXME what if we leave the passthrough mode right here?
|
# FIXME what if we leave the passthrough mode right here?
|
||||||
|
@ -170,6 +170,18 @@ class StatusBar(QWidget):
|
|||||||
self.txt.set_temptext('')
|
self.txt.set_temptext('')
|
||||||
self.clear_error()
|
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):
|
def resizeEvent(self, e):
|
||||||
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.
|
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user