Get rid of url_text_changed signal

Instead we simply use url_changed which (similar to Qt's urlChanged)
simply has a QUrl argument.
This commit is contained in:
Florian Bruhin 2016-07-11 14:28:51 +02:00
parent 5cbd540e15
commit a470bfc3f3
9 changed files with 41 additions and 35 deletions

View File

@ -445,11 +445,10 @@ class AbstractTab(QWidget):
load_progress = pyqtSignal(int)
load_finished = pyqtSignal(bool)
icon_changed = pyqtSignal(QIcon)
# FIXME:qtwebengine get rid of this altogether?
url_text_changed = pyqtSignal(str)
title_changed = pyqtSignal(str)
load_status_changed = pyqtSignal(str)
new_tab_requested = pyqtSignal(QUrl)
url_changed = pyqtSignal(QUrl)
shutting_down = pyqtSignal()
def __init__(self, win_id, parent=None):

View File

@ -316,9 +316,9 @@ class WebEngineTab(browsertab.AbstractTab):
page.loadProgress.connect(self._on_load_progress)
page.loadStarted.connect(self._on_load_started)
view.titleChanged.connect(self.title_changed)
view.urlChanged.connect(self.url_changed)
page.loadFinished.connect(self._on_load_finished)
page.certificate_error.connect(self._on_ssl_errors)
# FIXME:qtwebengine stub this?
# view.iconChanged.connect(self.icon_changed)
# view.scroll.pos_changed.connect(self.scroll.perc_changed)
# view.url_text_changed.connect(self.url_text_changed)

View File

@ -520,7 +520,7 @@ class WebKitTab(browsertab.AbstractTab):
frame.loadStarted.connect(self._on_load_started)
view.scroll_pos_changed.connect(self.scroll.perc_changed)
view.titleChanged.connect(self.title_changed)
view.url_text_changed.connect(self.url_text_changed)
view.urlChanged.connect(self.url_changed)
view.shutting_down.connect(self.shutting_down)
page.networkAccessManager().sslErrors.connect(self._on_ssl_errors)

View File

@ -56,7 +56,6 @@ class WebView(QWebView):
arg 1: x-position in %.
arg 2: y-position in %.
linkHovered: QWebPages linkHovered signal exposed.
url_text_changed: Current URL string changed.
mouse_wheel_zoom: Emitted when the page should be zoomed because the
mousewheel was used with ctrl.
arg 1: The angle delta of the wheel event (QPoint)
@ -65,7 +64,6 @@ class WebView(QWebView):
scroll_pos_changed = pyqtSignal(int, int)
linkHovered = pyqtSignal(str, str, str)
url_text_changed = pyqtSignal(str)
shutting_down = pyqtSignal()
mouse_wheel_zoom = pyqtSignal(QPoint)
@ -292,7 +290,6 @@ class WebView(QWebView):
urlstr = url.toDisplayString()
log.webview.debug("New title: {}".format(urlstr))
self.titleChanged.emit(urlstr)
self.url_text_changed.emit(url.toDisplayString())
self.load(url)
if url.scheme() == 'qute':
frame = self.page().mainFrame()
@ -318,7 +315,6 @@ class WebView(QWebView):
If the URL is invalid, we just ignore it here.
"""
if url.isValid():
self.url_text_changed.emit(url.toDisplayString())
if not self.title():
self.titleChanged.emit(self.url().toDisplayString())

View File

@ -183,7 +183,7 @@ class TabCompletionModel(base.BaseCompletionModel):
window=win_id)
for i in range(tabbed_browser.count()):
tab = tabbed_browser.widget(i)
tab.url_text_changed.connect(self.rebuild)
tab.url_changed.connect(self.rebuild)
tab.shutting_down.connect(self.delayed_rebuild)
tabbed_browser.new_tab.connect(self.on_new_tab)
objreg.get("app").new_window.connect(self.on_new_window)

View File

@ -349,7 +349,7 @@ class MainWindow(QWidget):
tabs.cur_load_started.connect(status.txt.on_load_started)
tabs.current_tab_changed.connect(status.url.on_tab_changed)
tabs.cur_url_text_changed.connect(status.url.set_url)
tabs.cur_url_changed.connect(status.url.set_url)
tabs.cur_link_hovered.connect(status.url.set_hover_url)
tabs.cur_load_status_changed.connect(status.url.on_load_status_changed)

View File

@ -129,14 +129,14 @@ class UrlText(textbase.TextBase):
self._normal_url_type = UrlType.normal
self._update_url()
@pyqtSlot(str)
def set_url(self, s):
@pyqtSlot(QUrl)
def set_url(self, url):
"""Setter to be used as a Qt slot.
Args:
s: The URL to set as string.
url: The URL to set as QUrl.
"""
self._normal_url = s
self._normal_url = url.toDisplayString()
self._normal_url_type = UrlType.normal
self._update_url()

View File

@ -75,7 +75,7 @@ class TabbedBrowser(tabwidget.TabWidget):
cur_load_finished: Current tab finished loading (load_finished)
cur_statusbar_message: Current tab got a statusbar message
(statusBarMessage)
cur_url_text_changed: Current URL text changed.
cur_url_changed: Current URL changed.
cur_link_hovered: Link hovered in current tab (link_hovered)
cur_scroll_perc_changed: Scroll percentage of current tab changed.
arg 1: x-position in %.
@ -93,7 +93,7 @@ class TabbedBrowser(tabwidget.TabWidget):
cur_load_started = pyqtSignal()
cur_load_finished = pyqtSignal(bool)
cur_statusbar_message = pyqtSignal(str)
cur_url_text_changed = pyqtSignal(str)
cur_url_changed = pyqtSignal(QUrl)
cur_link_hovered = pyqtSignal(str)
cur_scroll_perc_changed = pyqtSignal(int, int)
cur_load_status_changed = pyqtSignal(str)
@ -184,12 +184,12 @@ class TabbedBrowser(tabwidget.TabWidget):
tab.scroll.perc_changed.connect(
self._filter.create(self.cur_scroll_perc_changed, tab))
tab.scroll.perc_changed.connect(self.on_scroll_pos_changed)
tab.url_text_changed.connect(
self._filter.create(self.cur_url_text_changed, tab))
tab.url_changed.connect(
self._filter.create(self.cur_url_changed, tab))
tab.load_status_changed.connect(
self._filter.create(self.cur_load_status_changed, tab))
tab.url_text_changed.connect(
functools.partial(self.on_url_text_changed, tab))
tab.url_changed.connect(
functools.partial(self.on_url_changed, tab))
# misc
tab.title_changed.connect(
functools.partial(self.on_title_changed, tab))
@ -502,8 +502,8 @@ class TabbedBrowser(tabwidget.TabWidget):
if idx == self.currentIndex():
self.update_window_title()
@pyqtSlot(browsertab.AbstractTab, str)
def on_url_text_changed(self, tab, url):
@pyqtSlot(browsertab.AbstractTab, QUrl)
def on_url_changed(self, tab, url):
"""Set the new URL as title if there's no title yet.
Args:
@ -516,7 +516,7 @@ class TabbedBrowser(tabwidget.TabWidget):
# We can get signals for tabs we already deleted...
return
if not self.page_title(idx):
self.set_page_title(idx, url)
self.set_page_title(idx, url.toDisplayString())
@pyqtSlot(browsertab.AbstractTab, QIcon)
def on_icon_changed(self, tab, icon):

View File

@ -127,19 +127,30 @@ def test_on_tab_changed(url_widget, fake_web_tab, load_status, qurl):
assert url_widget.text() == qurl.toDisplayString()
@pytest.mark.parametrize('url_text, load_status, expected_status', [
('http://abc123.com/this/awesome/url.html', usertypes.LoadStatus.success,
url.UrlType.success),
('https://supersecret.gov/nsa/files.txt', usertypes.LoadStatus.success_https,
url.UrlType.success_https),
('Th1$ i$ n0t @ n0rm@L uRL! P@n1c! <-->', usertypes.LoadStatus.error,
url.UrlType.error),
('http://www.qutebrowser.org/CONTRIBUTING.html', usertypes.LoadStatus.loading,
url.UrlType.normal),
('www.whatisthisurl.com', usertypes.LoadStatus.warn, url.UrlType.warn)
@pytest.mark.parametrize('qurl, load_status, expected_status', [
(
QUrl('http://abc123.com/this/awesome/url.html'),
usertypes.LoadStatus.success,
url.UrlType.success
),
(
QUrl('https://supersecret.gov/nsa/files.txt'),
usertypes.LoadStatus.success_https,
url.UrlType.success_https
),
(
QUrl('http://www.qutebrowser.org/CONTRIBUTING.html'),
usertypes.LoadStatus.loading,
url.UrlType.normal
),
(
QUrl('www.whatisthisurl.com'),
usertypes.LoadStatus.warn,
url.UrlType.warn
),
])
def test_normal_url(url_widget, url_text, load_status, expected_status):
url_widget.set_url(url_text)
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.set_hover_url(url_text)
url_widget.set_hover_url("")