From d700d962afb3a4d136c6a1026a878b55f2c0693f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 22 Apr 2014 09:06:17 +0200 Subject: [PATCH] Add the ability to display persistent messages. --- qutebrowser/app.py | 2 ++ qutebrowser/utils/message.py | 14 +++++++++++++- qutebrowser/widgets/statusbar.py | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index a615a6c6d..0eba74758 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -262,6 +262,8 @@ class QuteBrowser(QApplication): self.mainwindow.tabs.set_mode.connect(self.set_mode) message.bridge.error.connect(self.mainwindow.status.disp_error) message.bridge.info.connect(self.mainwindow.status.disp_tmp_text) + message.bridge.text.connect(self.mainwindow.status.disp_text) + message.bridge.clear.connect(self.mainwindow.status.clear_text) self.config.style_changed.connect(style.invalidate_caches) self.config.changed.connect(self.mainwindow.tabs.on_config_changed) self.config.changed.connect( diff --git a/qutebrowser/utils/message.py b/qutebrowser/utils/message.py index 4e18a0a6e..caf947778 100644 --- a/qutebrowser/utils/message.py +++ b/qutebrowser/utils/message.py @@ -43,13 +43,25 @@ def error(message): def info(message): - """Display an info message in the statusbar.""" + """Display a temporary info message in the statusbar.""" bridge.info.emit(message) +def text(message): + """Display a persistent message in the statusbar.""" + bridge.text.emit(message) + + +def clear(): + """Clear a persistent message in the statusbar.""" + bridge.clear.emit() + + class MessageBridge(QObject): """Bridge for messages to be shown in the statusbar.""" error = pyqtSignal(str) info = pyqtSignal(str) + text = pyqtSignal(str) + clear = pyqtSignal() diff --git a/qutebrowser/widgets/statusbar.py b/qutebrowser/widgets/statusbar.py index d6027ca0f..1759d9835 100644 --- a/qutebrowser/widgets/statusbar.py +++ b/qutebrowser/widgets/statusbar.py @@ -170,6 +170,20 @@ class StatusBar(QWidget): """Clear a temporary text.""" self.disp_tmp_text('') + @pyqtSlot(str) + def disp_text(self, text): + """Display a persistent text. + + Args: + text: The text to display, or an empty string to clear. + """ + self.txt.normaltext = text + + @pyqtSlot() + def clear_text(self): + """Clear a persistent text.""" + self.disp_text('') + @pyqtSlot('QKeyEvent') def keypress(self, e): """Hide temporary error message if a key was pressed.