diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 216a0c2c2..c1f631465 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -207,7 +207,7 @@ DATA = OrderedDict([ "Whether to show vertical scrollbar for web content."), ('message-timeout', - SettingValue(types.Int(), '3000'), + SettingValue(types.Int(), '2000'), "Time (in ms) to show messages in the statusbar for."), )), diff --git a/qutebrowser/utils/message.py b/qutebrowser/utils/message.py index 2b33f117b..359c8097f 100644 --- a/qutebrowser/utils/message.py +++ b/qutebrowser/utils/message.py @@ -27,18 +27,30 @@ def instance(): return QCoreApplication.instance().messagebridge -def error(message): - """Display an error message in the statusbar.""" +def error(message, immediate=False): + """Display an error message in the statusbar. + + Args: + message: The message to display. + immediate: If set, message gets displayed immediately rather than + getting queued. + """ message = str(message) logging.error(message) - instance().error.emit(message) + instance().error.emit(message, immediate) -def info(message): - """Display a temporary info message in the statusbar.""" +def info(message, immediate=False): + """Display a temporary info message in the statusbar. + + Args: + message: The message to display. + immediate: If set, message gets displayed immediately rather than + getting queued. + """ message = str(message) logging.info(message) - instance().info.emit(message) + instance().info.emit(message, immediate) def text(message): @@ -62,7 +74,7 @@ class MessageBridge(QObject): """Bridge for messages to be shown in the statusbar.""" - error = pyqtSignal(str) - info = pyqtSignal(str) + error = pyqtSignal(str, bool) + info = pyqtSignal(str, bool) text = pyqtSignal(str) set_cmd_text = pyqtSignal(str) diff --git a/qutebrowser/widgets/statusbar/bar.py b/qutebrowser/widgets/statusbar/bar.py index b1a02057d..f19da8eeb 100644 --- a/qutebrowser/widgets/statusbar/bar.py +++ b/qutebrowser/widgets/statusbar/bar.py @@ -181,9 +181,15 @@ class StatusBar(QWidget): self._text_pop_timer.start() self._stack.setCurrentWidget(self.txt) - @pyqtSlot(str) - def _disp_text(self, text, error): - """Inner logic for disp_error and disp_temp_text.""" + def _disp_text(self, text, error, immediate): + """Inner logic for disp_error and disp_temp_text. + + Args: + text: The message to display. + error: Whether it's an error message (True) or normal text (False) + immediate: If set, message gets displayed immediately rather than + getting queued. + """ logging.debug("Displaying text: {} (error={})".format(text, error)) now = datetime.now() mindelta = config.get('general', 'message-timeout') @@ -191,8 +197,8 @@ class StatusBar(QWidget): else now - self._last_text_time) self._last_text_time = now logging.debug("queue: {} / delta: {}".format(self._text_queue, delta)) - if not self._text_queue and ( - delta is None or delta.total_seconds() * 1000.0 > mindelta): + if immediate or (not self._text_queue and ( + delta is None or delta.total_seconds() * 1000.0 > mindelta)): # If the queue is empty and we didn't print messages for long # enough, we can take the short route and display the message # immediately. We then start the pop_timer only to restore the @@ -212,15 +218,27 @@ class StatusBar(QWidget): self._text_queue.append((error, text)) self._text_pop_timer.start() - @pyqtSlot(str) - def disp_error(self, text): - """Display an error in the statusbar.""" - self._disp_text(text, True) + @pyqtSlot(str, bool) + def disp_error(self, text, immediate): + """Display an error in the statusbar. - @pyqtSlot(str) - def disp_temp_text(self, text): - """Add a temporary text to the queue.""" - self._disp_text(text, False) + Args: + text: The message to display. + immediate: If set, message gets displayed immediately rather than + getting queued. + """ + self._disp_text(text, True, immediate) + + @pyqtSlot(str, bool) + def disp_temp_text(self, text, immediate): + """Display a temporary text in the statusbar. + + Args: + text: The message to display. + immediate: If set, message gets displayed immediately rather than + getting queued. + """ + self._disp_text(text, False, immediate) @pyqtSlot(str) def set_text(self, val): diff --git a/qutebrowser/widgets/webview.py b/qutebrowser/widgets/webview.py index f8760789f..8b836ad66 100644 --- a/qutebrowser/widgets/webview.py +++ b/qutebrowser/widgets/webview.py @@ -309,7 +309,7 @@ class WebView(QWebView): if perc < 0: raise CommandError("Can't zoom {}%!".format(perc)) self.setZoomFactor(float(perc) / 100) - message.info("Zoom level: {}%".format(perc)) + message.info("Zoom level: {}%".format(perc), immediate=True) def zoom(self, offset): """Increase/Decrease the zoom level.