From 6acac5cb716a75fd69f51bfd8ef06a618a38c71c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 20 Jan 2014 07:01:39 +0100 Subject: [PATCH] Display keystring in statusbar --- qutebrowser/app.py | 2 ++ qutebrowser/commands/keys.py | 5 +++++ qutebrowser/widgets/statusbar.py | 8 ++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index d2104e554..2ac8b1eda 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -21,6 +21,8 @@ class QuteBrowser(QApplication): self.mainwindow.status.cmd.got_cmd.connect(self.commandparser.parse) self.mainwindow.status.cmd.got_cmd.connect(self.mainwindow.tabs.setFocus) self.commandparser.error.connect(self.mainwindow.status.disp_error) + self.keyparser.keystring_updated.connect( + self.mainwindow.status.txt.set_keystring) self.init_cmds() self.mainwindow.show() diff --git a/qutebrowser/commands/keys.py b/qutebrowser/commands/keys.py index 92326dfc4..72a5538b4 100644 --- a/qutebrowser/commands/keys.py +++ b/qutebrowser/commands/keys.py @@ -7,6 +7,7 @@ import re class KeyParser(QObject): keystring = '' set_cmd_text = pyqtSignal(str) + keystring_updated = pyqtSignal(str) key_to_cmd = {} def from_cmd_dict(self, d): @@ -16,6 +17,10 @@ class KeyParser(QObject): self.key_to_cmd[cmd.key] = cmd def handle(self, e): + self._handle(e) + self.keystring_updated.emit(self.keystring) + + def _handle(self, e): logging.debug('Got key: {} / text: "{}"'.format(e.key(), e.text())) txt = e.text().strip() if not txt: diff --git a/qutebrowser/widgets/statusbar.py b/qutebrowser/widgets/statusbar.py index 68edf0482..9ebb89c05 100644 --- a/qutebrowser/widgets/statusbar.py +++ b/qutebrowser/widgets/statusbar.py @@ -1,6 +1,7 @@ from PyQt5.QtWidgets import QLineEdit, QHBoxLayout, QLabel, QWidget, QShortcut, QProgressBar, QSizePolicy from PyQt5.QtCore import pyqtSignal, Qt, QSize from PyQt5.QtGui import QValidator, QKeySequence +import logging class StatusBar(QWidget): has_error = False @@ -101,9 +102,12 @@ class StatusText(QLabel): super().__setattr__(name, value) self.update() + def set_keystring(self, s): + self.keystring = s + def update(self): - self.setText(''.join([self.keystring, self.error, self.text, - self.scrollperc])) + super().setText(' '.join([self.keystring, self.error, self.text, + self.scrollperc])) class StatusCommand(QLineEdit): got_cmd = pyqtSignal(str)