Don't use properties for AbstractTab
Otherwise exceptions in there could be hidden by Python/PyQt. Some places are not changed yet, as there are also other renames in the next commits.
This commit is contained in:
parent
ecd399181d
commit
2befebaf3a
@ -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
|
||||
|
||||
|
@ -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 = '<AttributeError>'
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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')]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user