summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-06-17 16:14:09 +0200
committerFlorian Bruhin <me@the-compiler.org>2020-06-17 16:14:09 +0200
commit4d4954173787d8ea8152c243a3d6a03b5022a12f (patch)
tree7a27a6fce574b3fae929704f9471df83baee222d
parentd6eebbd3f91f73aae660a553633999ed82993096 (diff)
downloadqutebrowser-4d4954173787d8ea8152c243a3d6a03b5022a12f.tar.gz
qutebrowser-4d4954173787d8ea8152c243a3d6a03b5022a12f.zip
Show partial keystrings for all modes in statusbar
Closes #2817
-rw-r--r--doc/changelog.asciidoc1
-rw-r--r--qutebrowser/keyinput/modeman.py7
-rw-r--r--qutebrowser/mainwindow/mainwindow.py9
-rw-r--r--qutebrowser/mainwindow/statusbar/keystring.py7
-rw-r--r--qutebrowser/misc/keyhintwidget.py6
5 files changed, 21 insertions, 9 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index 537c742d2..a90d46954 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -54,6 +54,7 @@ Changed
former distinction was mainly an implementation detail, and the accepted
values shouldn't have changed.
* `input.rocker_gestures` has been renamed to `input.mouse.rocker_gestures`.
+- The statusbar now shows partial keychains in all modes (e.g. while hinting)
- Small performance improvements.
Added
diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py
index 2ec956422..74ab8a27c 100644
--- a/qutebrowser/keyinput/modeman.py
+++ b/qutebrowser/keyinput/modeman.py
@@ -243,10 +243,15 @@ class ModeManager(QObject):
arg1: The mode which has been left.
arg2: The new current mode.
arg3: The window ID of this mode manager.
+ keystring_updated: Emitted when the keystring was updated in any mode.
+ arg 1: The mode in which the keystring has been
+ updated.
+ arg 2: The new key string.
"""
entered = pyqtSignal(usertypes.KeyMode, int)
left = pyqtSignal(usertypes.KeyMode, usertypes.KeyMode, int)
+ keystring_updated = pyqtSignal(usertypes.KeyMode, str)
def __init__(self, win_id: int, parent: QObject = None) -> None:
super().__init__(parent)
@@ -332,6 +337,8 @@ class ModeManager(QObject):
assert parser is not None
self.parsers[mode] = parser
parser.request_leave.connect(self.leave)
+ parser.keystring_updated.connect(
+ functools.partial(self.keystring_updated.emit, mode))
def enter(self, mode: usertypes.KeyMode,
reason: str = None,
diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py
index 41f97868c..cf77866f2 100644
--- a/qutebrowser/mainwindow/mainwindow.py
+++ b/qutebrowser/mainwindow/mainwindow.py
@@ -505,9 +505,8 @@ class MainWindow(QWidget):
message.global_bridge.mode_left) # type: ignore[arg-type]
# commands
- normal_parser = mode_manager.parsers[usertypes.KeyMode.normal]
- normal_parser.keystring_updated.connect(
- self.status.keystring.setText)
+ mode_manager.keystring_updated.connect(
+ self.status.keystring.on_keystring_updated)
self.status.cmd.got_cmd[str].connect( # type: ignore[index]
self._commandrunner.run_safely)
self.status.cmd.got_cmd[str, int].connect( # type: ignore[index]
@@ -518,9 +517,7 @@ class MainWindow(QWidget):
self._command_dispatcher.search)
# key hint popup
- for mode, parser in mode_manager.parsers.items():
- parser.keystring_updated.connect(functools.partial(
- self._keyhint.update_keyhint, mode.name))
+ mode_manager.keystring_updated.connect(self._keyhint.update_keyhint)
# messages
message.global_bridge.show_message.connect(
diff --git a/qutebrowser/mainwindow/statusbar/keystring.py b/qutebrowser/mainwindow/statusbar/keystring.py
index a3b64892f..a64c8e0e2 100644
--- a/qutebrowser/mainwindow/statusbar/keystring.py
+++ b/qutebrowser/mainwindow/statusbar/keystring.py
@@ -19,9 +19,16 @@
"""Keychain string displayed in the statusbar."""
+from PyQt5.QtCore import pyqtSlot
+
from qutebrowser.mainwindow.statusbar import textbase
+from qutebrowser.utils import usertypes
class KeyString(textbase.TextBase):
"""Keychain string displayed in the statusbar."""
+
+ @pyqtSlot(usertypes.KeyMode, str)
+ def on_keystring_updated(self, _mode, keystr):
+ self.setText(keystr)
diff --git a/qutebrowser/misc/keyhintwidget.py b/qutebrowser/misc/keyhintwidget.py
index 89dac83f2..11bb14d66 100644
--- a/qutebrowser/misc/keyhintwidget.py
+++ b/qutebrowser/misc/keyhintwidget.py
@@ -82,8 +82,8 @@ class KeyHintView(QLabel):
self.update_geometry.emit()
super().showEvent(e)
- @pyqtSlot(str)
- def update_keyhint(self, modename, prefix):
+ @pyqtSlot(usertypes.KeyMode, str)
+ def update_keyhint(self, mode, prefix):
"""Show hints for the given prefix (or hide if prefix is empty).
Args:
@@ -108,7 +108,7 @@ class KeyHintView(QLabel):
cmd = objects.commands.get(cmdname)
return cmd and cmd.takes_count()
- bindings_dict = config.key_instance.get_bindings_for(modename)
+ bindings_dict = config.key_instance.get_bindings_for(mode.name)
bindings = [(k, v) for (k, v) in sorted(bindings_dict.items())
if keyutils.KeySequence.parse(prefix).matches(k) and
not blacklisted(str(k)) and