diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index faff46d36..ab2ecc2a7 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -48,6 +48,7 @@ Changed work properly anymore. - Using `:download` now uses the page's title as filename. - Using `:back` or `:forward` with a count now skips intermediate pages. +- When there are multiple messages shown, the timeout is increased. Fixes ~~~~~ diff --git a/README.asciidoc b/README.asciidoc index 825c6fd6b..530379242 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -192,6 +192,7 @@ Contributors, sorted by the number of commits in descending order: * Peter Vilim * Jacob Sword * knaggita +* Yashar Shahi * Oliver Caldwell * Nikolay Amiantov * Marius diff --git a/qutebrowser/mainwindow/messageview.py b/qutebrowser/mainwindow/messageview.py index 7d0d2b682..657835dba 100644 --- a/qutebrowser/mainwindow/messageview.py +++ b/qutebrowser/mainwindow/messageview.py @@ -83,7 +83,6 @@ class MessageView(QWidget): self._clear_timer = QTimer() self._clear_timer.timeout.connect(self.clear_messages) - self._set_clear_timer_interval() objreg.get('config').changed.connect(self._set_clear_timer_interval) self._last_text = None @@ -99,7 +98,8 @@ class MessageView(QWidget): def _set_clear_timer_interval(self): """Configure self._clear_timer according to the config.""" interval = config.get('ui', 'message-timeout') - if interval != 0: + if interval > 0: + interval *= min(5, len(self._messages)) self._clear_timer.setInterval(interval) @pyqtSlot() @@ -127,12 +127,13 @@ class MessageView(QWidget): widget = Message(level, text, replace=replace, parent=self) self._vbox.addWidget(widget) widget.show() - if config.get('ui', 'message-timeout') != 0: - self._clear_timer.start() self._messages.append(widget) self._last_text = text self.show() self.update_geometry.emit() + if config.get('ui', 'message-timeout') != 0: + self._set_clear_timer_interval() + self._clear_timer.start() def mousePressEvent(self, e): """Clear messages when they are clicked on.""" diff --git a/tests/unit/mainwindow/test_messageview.py b/tests/unit/mainwindow/test_messageview.py index ebecc9398..782e38ae5 100644 --- a/tests/unit/mainwindow/test_messageview.py +++ b/tests/unit/mainwindow/test_messageview.py @@ -104,6 +104,19 @@ def test_changing_timer_with_messages_shown(qtbot, view, config_stub): config_stub.set('ui', 'message-timeout', 100) +@pytest.mark.parametrize('count, expected', [(1, 100), (3, 300), + (5, 500), (7, 500)]) +def test_show_multiple_messages_longer(view, count, expected): + """When there are multiple messages, messages should be shown longer. + + There is an upper maximum to avoid messages never disappearing. + """ + for message_number in range(1, count+1): + view.show_message(usertypes.MessageLevel.info, + 'test ' + str(message_number)) + assert view._clear_timer.interval() == expected + + @pytest.mark.parametrize('replace1, replace2, length', [ (False, False, 2), # Two stacked messages (True, True, 1), # Two replaceable messages