diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index d8297ac94..16a0fffe7 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -615,7 +615,7 @@ class CommandDispatcher: count: multiplier """ tab = self._current_widget() - if not tab.cur_url.isValid(): + if not tab.url().isValid(): # See https://github.com/The-Compiler/qutebrowser/issues/701 return diff --git a/qutebrowser/browser/tab.py b/qutebrowser/browser/tab.py index 48a1b64b2..beac07e35 100644 --- a/qutebrowser/browser/tab.py +++ b/qutebrowser/browser/tab.py @@ -461,15 +461,12 @@ class AbstractTab(QWidget): self.data.viewing_source = False self.load_started.emit() - @property - def cur_url(self): + def url(self): raise NotImplementedError - @property def progress(self): raise NotImplementedError - @property def load_status(self): raise NotImplementedError @@ -518,7 +515,7 @@ class AbstractTab(QWidget): def __repr__(self): try: - url = utils.elide(self.cur_url.toDisplayString(QUrl.EncodeUnicode), + url = utils.elide(self.url().toDisplayString(QUrl.EncodeUnicode), 100) except AttributeError: url = '' diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index e54ba6dda..940c04a15 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -187,15 +187,12 @@ class WebEngineViewTab(tab.AbstractTab): def openurl(self, url): self._widget.load(url) - @property - def cur_url(self): + def url(self): return self._widget.url() - @property def progress(self): return 0 # FIXME:qtwebengine - @property def load_status(self): return usertypes.LoadStatus.success diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index 9fdca2b32..55e75e069 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -288,7 +288,7 @@ class WebViewCaret(tabmod.AbstractCaret): url = selected_element.attrib['href'] except KeyError: raise tabmod.WebTabError('Anchor element without href!') - url = self._tab.cur_url.resolved(QUrl(url)) + url = self._tab.url().resolved(QUrl(url)) if tab: self._tab.new_tab_requested.emit(url) else: @@ -467,15 +467,12 @@ class WebViewTab(tabmod.AbstractTab): def openurl(self, url): self._widget.openurl(url) - @property - def cur_url(self): + def url(self): return self._widget.cur_url - @property def progress(self): return self._widget.progress - @property def load_status(self): return self._widget.load_status diff --git a/qutebrowser/completion/models/miscmodels.py b/qutebrowser/completion/models/miscmodels.py index 5ce8bceb0..e781142fe 100644 --- a/qutebrowser/completion/models/miscmodels.py +++ b/qutebrowser/completion/models/miscmodels.py @@ -241,12 +241,12 @@ class TabCompletionModel(base.BaseCompletionModel): tab = tabbed_browser.widget(idx) if idx >= c.rowCount(): self.new_item(c, "{}/{}".format(win_id, idx + 1), - tab.cur_url.toDisplayString(), + tab.url().toDisplayString(), tabbed_browser.page_title(idx)) else: c.child(idx, 0).setData("{}/{}".format(win_id, idx + 1), Qt.DisplayRole) - c.child(idx, 1).setData(tab.cur_url.toDisplayString(), + c.child(idx, 1).setData(tab.url().toDisplayString(), Qt.DisplayRole) c.child(idx, 2).setData(tabbed_browser.page_title(idx), Qt.DisplayRole) diff --git a/qutebrowser/mainwindow/statusbar/progress.py b/qutebrowser/mainwindow/statusbar/progress.py index 9c4e3f4b3..0e1933fdb 100644 --- a/qutebrowser/mainwindow/statusbar/progress.py +++ b/qutebrowser/mainwindow/statusbar/progress.py @@ -66,8 +66,8 @@ class Progress(QProgressBar): # This should never happen, but for some weird reason it does # sometimes. return # pragma: no cover - self.setValue(tab.progress) - if tab.load_status == usertypes.LoadStatus.loading: + self.setValue(tab.progress()) + if tab.load_status() == usertypes.LoadStatus.loading: self.show() else: self.hide() diff --git a/qutebrowser/mainwindow/statusbar/url.py b/qutebrowser/mainwindow/statusbar/url.py index 5eb91501a..27083c10b 100644 --- a/qutebrowser/mainwindow/statusbar/url.py +++ b/qutebrowser/mainwindow/statusbar/url.py @@ -164,6 +164,6 @@ class UrlText(textbase.TextBase): def on_tab_changed(self, tab): """Update URL if the tab changed.""" self._hover_url = None - self._normal_url = tab.cur_url.toDisplayString() - self.on_load_status_changed(tab.load_status.name) + self._normal_url = tab.url().toDisplayString() + self.on_load_status_changed(tab.load_status().name) self._update_url() diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 823348668..47751a47e 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -266,11 +266,11 @@ class TabbedBrowser(tabwidget.TabWidget): window=self._win_id): objreg.delete('last-focused-tab', scope='window', window=self._win_id) - if tab.cur_url.isValid(): + if tab.url().isValid(): history_data = tab.history.serialize() - entry = UndoEntry(tab.cur_url, history_data) + entry = UndoEntry(tab.url(), history_data) self._undo_stack.append(entry) - elif tab.cur_url.isEmpty(): + elif tab.url().isEmpty(): # There are some good reasons why a URL could be empty # (target="_blank" with a download, see [1]), so we silently ignore # this. @@ -280,7 +280,7 @@ class TabbedBrowser(tabwidget.TabWidget): # We display a warnings for URLs which are not empty but invalid - # but we don't return here because we want the tab to close either # way. - urlutils.invalid_url_error(self._win_id, tab.cur_url, "saving tab") + urlutils.invalid_url_error(self._win_id, tab.url(), "saving tab") tab.shutdown() self.removeTab(idx) tab.deleteLater() @@ -298,7 +298,7 @@ class TabbedBrowser(tabwidget.TabWidget): 'startpage': QUrl(config.get('general', 'startpage')[0]), 'default-page': config.get('general', 'default-page'), } - first_tab_url = self.widget(0).cur_url + first_tab_url = self.widget(0).url() last_close_urlstr = urls[last_close].toString().rstrip('/') first_tab_urlstr = first_tab_url.toString().rstrip('/') last_close_url_used = first_tab_urlstr == last_close_urlstr diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py index 9ceb49a22..168e23062 100644 --- a/qutebrowser/misc/crashsignal.py +++ b/qutebrowser/misc/crashsignal.py @@ -116,7 +116,7 @@ class CrashHandler(QObject): window=win_id) for tab in tabbed_browser.widgets(): try: - urlstr = tab.cur_url.toString( + urlstr = tab.url().toString( QUrl.RemovePassword | QUrl.FullyEncoded) if urlstr: win_pages.append(urlstr) diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index 608f5cade..ad6e4b260 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -342,7 +342,7 @@ def test_tab_completion_delete(stubs, qtbot, app_stub, win_registry, view = _mock_view_index(model, 0, 1, qtbot) qtbot.add_widget(view) model.delete_cur_item(view) - actual = [tab.cur_url for tab in tabbed_browser_stubs[0].tabs] + actual = [tab.url() for tab in tabbed_browser_stubs[0].tabs] assert actual == [QUrl('https://github.com'), QUrl('https://duckduckgo.com')]