Add the ability to display persistent messages.

This commit is contained in:
Florian Bruhin 2014-04-22 09:06:17 +02:00
parent 1740d4c60f
commit d700d962af
3 changed files with 29 additions and 1 deletions

View File

@ -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(

View File

@ -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()

View File

@ -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.