This commit is contained in:
Florian Bruhin 2016-09-15 13:56:27 +02:00
parent e32bbfa8f7
commit 7e30792bfe
8 changed files with 13 additions and 11 deletions

View File

@ -259,8 +259,8 @@ class HostBlocker:
self._blocked_hosts.add(host)
log.misc.debug("{}: read {} lines".format(byte_io.name, line_count))
if error_count > 0:
message.error("adblock: {} read errors for {}".format(error_count,
byte_io.name))
message.error("adblock: {} read errors for {}".format(
error_count, byte_io.name))
def on_lists_downloaded(self):
"""Install block lists after files have been downloaded."""

View File

@ -69,6 +69,8 @@ class Message(QLabel):
class MessageView(QWidget):
"""Widget which stacks error/warning/info messages."""
reposition = pyqtSignal()
def __init__(self, parent=None):
@ -87,13 +89,16 @@ class MessageView(QWidget):
@config.change_filter('ui', 'message-timeout')
def _set_clear_timer_interval(self):
"""Configure self._clear_timer according to the config."""
self._clear_timer.setInterval(config.get('ui', 'message-timeout'))
def message_height(self):
"""Get the total height of all messages."""
return sum(label.sizeHint().height() for label in self._messages)
@pyqtSlot()
def _clear_messages(self):
"""Hide and delete all messages."""
for widget in self._messages:
self._vbox.removeWidget(widget)
widget.hide()
@ -105,6 +110,7 @@ class MessageView(QWidget):
@pyqtSlot(usertypes.MessageLevel, str)
def show_message(self, level, text):
"""Show the given message with the given MessageLevel."""
if text == self._last_text:
return

View File

@ -19,10 +19,7 @@
"""The main statusbar widget."""
import collections
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, pyqtProperty, Qt, QTime, QSize,
QTimer)
from PyQt5.QtCore import pyqtSignal, pyqtSlot, pyqtProperty, Qt, QSize, QTimer
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QStackedLayout, QSizePolicy
from qutebrowser.config import config, style

View File

@ -153,8 +153,8 @@ class GUIProcess(QObject):
log.procs.debug("Process started.")
self._started = True
else:
message.error("Error while spawning {}: {}.".format(self._what,
self._proc.error()))
message.error("Error while spawning {}: {}.".format(
self._what, self._proc.error()))
def exit_status(self):
return self._proc.exitStatus()

View File

@ -25,7 +25,6 @@
import traceback
from PyQt5.QtCore import pyqtSignal, QObject
from PyQt5.QtWidgets import QApplication
from qutebrowser.utils import usertypes, log, objreg, utils

View File

@ -86,6 +86,7 @@ def whitelist_generator():
yield 'qutebrowser.utils.log.QtWarningFilter.filter'
yield 'qutebrowser.browser.pdfjs.is_available'
yield 'QEvent.posted'
yield 'log_stack' # from message.py
# vulture doesn't notice the hasattr() and thus thinks netrc_used is unused
# in NetworkManager.on_authentication_required
yield 'PyQt5.QtNetwork.QNetworkReply.netrc_used'

View File

@ -189,7 +189,7 @@ def test_error(qtbot, proc, caplog, message_mock):
def test_exit_unsuccessful(qtbot, proc, message_mock, py_proc, caplog):
with caplog.at_level(logging.ERROR):
with qtbot.waitSignal(proc.finished, timeout=10000):
proc.start(*py_proc('import sys; sys.exit(1)'))
proc.start(*py_proc('import sys; sys.exit(1)'))
msg = message_mock.getmsg(usertypes.MessageLevel.error)
assert msg.text == "Testprocess exited with status 1."

View File

@ -21,7 +21,6 @@
import sys
import enum
import datetime
import os.path
import io
import logging