Merge branch 'pr/2808'
This commit is contained in:
commit
c0426d3482
@ -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
|
||||
~~~~~
|
||||
|
@ -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
|
||||
|
@ -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."""
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user