Use enum values for load_status_changed
This commit is contained in:
parent
a6d3a935d3
commit
0104490978
@ -837,7 +837,7 @@ class AbstractTab(QWidget):
|
||||
load_finished = pyqtSignal(bool)
|
||||
icon_changed = pyqtSignal(QIcon)
|
||||
title_changed = pyqtSignal(str)
|
||||
load_status_changed = pyqtSignal(str)
|
||||
load_status_changed = pyqtSignal(usertypes.LoadStatus)
|
||||
new_tab_requested = pyqtSignal(QUrl)
|
||||
url_changed = pyqtSignal(QUrl)
|
||||
shutting_down = pyqtSignal()
|
||||
@ -906,7 +906,7 @@ class AbstractTab(QWidget):
|
||||
raise TypeError("Type {} is no LoadStatus member!".format(val))
|
||||
log.webview.debug("load status for {}: {}".format(repr(self), val))
|
||||
self._load_status = val
|
||||
self.load_status_changed.emit(val.name)
|
||||
self.load_status_changed.emit(val)
|
||||
|
||||
def send_event(self, evt: QEvent) -> None:
|
||||
"""Send the given event to the underlying widget.
|
||||
|
@ -112,19 +112,18 @@ class UrlText(textbase.TextBase):
|
||||
self._urltype = UrlType.normal
|
||||
config.set_register_stylesheet(self, update=False)
|
||||
|
||||
@pyqtSlot(str)
|
||||
def on_load_status_changed(self, status_str):
|
||||
@pyqtSlot(usertypes.LoadStatus)
|
||||
def on_load_status_changed(self, status):
|
||||
"""Slot for load_status_changed. Sets URL color accordingly.
|
||||
|
||||
Args:
|
||||
status_str: The LoadStatus as string.
|
||||
status: The usertypes.LoadStatus.
|
||||
"""
|
||||
status = usertypes.LoadStatus[status_str]
|
||||
if status in [usertypes.LoadStatus.success,
|
||||
usertypes.LoadStatus.success_https,
|
||||
usertypes.LoadStatus.error,
|
||||
usertypes.LoadStatus.warn]:
|
||||
self._normal_url_type = UrlType[status_str]
|
||||
self._normal_url_type = UrlType[status.name]
|
||||
else:
|
||||
self._normal_url_type = UrlType.normal
|
||||
self._update_url()
|
||||
@ -172,5 +171,5 @@ class UrlText(textbase.TextBase):
|
||||
self._normal_url = urlutils.safe_display_string(tab.url())
|
||||
else:
|
||||
self._normal_url = ''
|
||||
self.on_load_status_changed(tab.load_status().name)
|
||||
self.on_load_status_changed(tab.load_status())
|
||||
self._update_url()
|
||||
|
@ -102,7 +102,7 @@ class TabbedBrowser(QWidget):
|
||||
cur_url_changed = pyqtSignal(QUrl)
|
||||
cur_link_hovered = pyqtSignal(str)
|
||||
cur_scroll_perc_changed = pyqtSignal(int, int)
|
||||
cur_load_status_changed = pyqtSignal(str)
|
||||
cur_load_status_changed = pyqtSignal(usertypes.LoadStatus)
|
||||
cur_fullscreen_requested = pyqtSignal(bool)
|
||||
cur_caret_selection_toggled = pyqtSignal(bool)
|
||||
close_window = pyqtSignal()
|
||||
|
@ -89,7 +89,7 @@ def test_set_url(url_widget, url_text, expected, which):
|
||||
def test_on_load_status_changed(url_widget, status, expected):
|
||||
"""Test text when status is changed."""
|
||||
url_widget.set_url(QUrl('www.example.com'))
|
||||
url_widget.on_load_status_changed(status.name)
|
||||
url_widget.on_load_status_changed(status)
|
||||
assert url_widget._urltype == expected
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ def test_on_tab_changed(url_widget, fake_web_tab, load_status, qurl):
|
||||
])
|
||||
def test_normal_url(url_widget, qurl, load_status, expected_status):
|
||||
url_widget.set_url(qurl)
|
||||
url_widget.on_load_status_changed(load_status.name)
|
||||
url_widget.on_load_status_changed(load_status)
|
||||
url_widget.set_hover_url(qurl.toDisplayString())
|
||||
url_widget.set_hover_url("")
|
||||
assert url_widget.text() == qurl.toDisplayString()
|
||||
|
Loading…
Reference in New Issue
Block a user