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
|
count: multiplier
|
||||||
"""
|
"""
|
||||||
tab = self._current_widget()
|
tab = self._current_widget()
|
||||||
if not tab.cur_url.isValid():
|
if not tab.url().isValid():
|
||||||
# See https://github.com/The-Compiler/qutebrowser/issues/701
|
# See https://github.com/The-Compiler/qutebrowser/issues/701
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -461,15 +461,12 @@ class AbstractTab(QWidget):
|
|||||||
self.data.viewing_source = False
|
self.data.viewing_source = False
|
||||||
self.load_started.emit()
|
self.load_started.emit()
|
||||||
|
|
||||||
@property
|
def url(self):
|
||||||
def cur_url(self):
|
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@property
|
|
||||||
def progress(self):
|
def progress(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@property
|
|
||||||
def load_status(self):
|
def load_status(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@ -518,7 +515,7 @@ class AbstractTab(QWidget):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
try:
|
try:
|
||||||
url = utils.elide(self.cur_url.toDisplayString(QUrl.EncodeUnicode),
|
url = utils.elide(self.url().toDisplayString(QUrl.EncodeUnicode),
|
||||||
100)
|
100)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
url = '<AttributeError>'
|
url = '<AttributeError>'
|
||||||
|
@ -187,15 +187,12 @@ class WebEngineViewTab(tab.AbstractTab):
|
|||||||
def openurl(self, url):
|
def openurl(self, url):
|
||||||
self._widget.load(url)
|
self._widget.load(url)
|
||||||
|
|
||||||
@property
|
def url(self):
|
||||||
def cur_url(self):
|
|
||||||
return self._widget.url()
|
return self._widget.url()
|
||||||
|
|
||||||
@property
|
|
||||||
def progress(self):
|
def progress(self):
|
||||||
return 0 # FIXME:qtwebengine
|
return 0 # FIXME:qtwebengine
|
||||||
|
|
||||||
@property
|
|
||||||
def load_status(self):
|
def load_status(self):
|
||||||
return usertypes.LoadStatus.success
|
return usertypes.LoadStatus.success
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ class WebViewCaret(tabmod.AbstractCaret):
|
|||||||
url = selected_element.attrib['href']
|
url = selected_element.attrib['href']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise tabmod.WebTabError('Anchor element without href!')
|
raise tabmod.WebTabError('Anchor element without href!')
|
||||||
url = self._tab.cur_url.resolved(QUrl(url))
|
url = self._tab.url().resolved(QUrl(url))
|
||||||
if tab:
|
if tab:
|
||||||
self._tab.new_tab_requested.emit(url)
|
self._tab.new_tab_requested.emit(url)
|
||||||
else:
|
else:
|
||||||
@ -467,15 +467,12 @@ class WebViewTab(tabmod.AbstractTab):
|
|||||||
def openurl(self, url):
|
def openurl(self, url):
|
||||||
self._widget.openurl(url)
|
self._widget.openurl(url)
|
||||||
|
|
||||||
@property
|
def url(self):
|
||||||
def cur_url(self):
|
|
||||||
return self._widget.cur_url
|
return self._widget.cur_url
|
||||||
|
|
||||||
@property
|
|
||||||
def progress(self):
|
def progress(self):
|
||||||
return self._widget.progress
|
return self._widget.progress
|
||||||
|
|
||||||
@property
|
|
||||||
def load_status(self):
|
def load_status(self):
|
||||||
return self._widget.load_status
|
return self._widget.load_status
|
||||||
|
|
||||||
|
@ -241,12 +241,12 @@ class TabCompletionModel(base.BaseCompletionModel):
|
|||||||
tab = tabbed_browser.widget(idx)
|
tab = tabbed_browser.widget(idx)
|
||||||
if idx >= c.rowCount():
|
if idx >= c.rowCount():
|
||||||
self.new_item(c, "{}/{}".format(win_id, idx + 1),
|
self.new_item(c, "{}/{}".format(win_id, idx + 1),
|
||||||
tab.cur_url.toDisplayString(),
|
tab.url().toDisplayString(),
|
||||||
tabbed_browser.page_title(idx))
|
tabbed_browser.page_title(idx))
|
||||||
else:
|
else:
|
||||||
c.child(idx, 0).setData("{}/{}".format(win_id, idx + 1),
|
c.child(idx, 0).setData("{}/{}".format(win_id, idx + 1),
|
||||||
Qt.DisplayRole)
|
Qt.DisplayRole)
|
||||||
c.child(idx, 1).setData(tab.cur_url.toDisplayString(),
|
c.child(idx, 1).setData(tab.url().toDisplayString(),
|
||||||
Qt.DisplayRole)
|
Qt.DisplayRole)
|
||||||
c.child(idx, 2).setData(tabbed_browser.page_title(idx),
|
c.child(idx, 2).setData(tabbed_browser.page_title(idx),
|
||||||
Qt.DisplayRole)
|
Qt.DisplayRole)
|
||||||
|
@ -66,8 +66,8 @@ class Progress(QProgressBar):
|
|||||||
# This should never happen, but for some weird reason it does
|
# This should never happen, but for some weird reason it does
|
||||||
# sometimes.
|
# sometimes.
|
||||||
return # pragma: no cover
|
return # pragma: no cover
|
||||||
self.setValue(tab.progress)
|
self.setValue(tab.progress())
|
||||||
if tab.load_status == usertypes.LoadStatus.loading:
|
if tab.load_status() == usertypes.LoadStatus.loading:
|
||||||
self.show()
|
self.show()
|
||||||
else:
|
else:
|
||||||
self.hide()
|
self.hide()
|
||||||
|
@ -164,6 +164,6 @@ class UrlText(textbase.TextBase):
|
|||||||
def on_tab_changed(self, tab):
|
def on_tab_changed(self, tab):
|
||||||
"""Update URL if the tab changed."""
|
"""Update URL if the tab changed."""
|
||||||
self._hover_url = None
|
self._hover_url = None
|
||||||
self._normal_url = tab.cur_url.toDisplayString()
|
self._normal_url = tab.url().toDisplayString()
|
||||||
self.on_load_status_changed(tab.load_status.name)
|
self.on_load_status_changed(tab.load_status().name)
|
||||||
self._update_url()
|
self._update_url()
|
||||||
|
@ -266,11 +266,11 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
window=self._win_id):
|
window=self._win_id):
|
||||||
objreg.delete('last-focused-tab', scope='window',
|
objreg.delete('last-focused-tab', scope='window',
|
||||||
window=self._win_id)
|
window=self._win_id)
|
||||||
if tab.cur_url.isValid():
|
if tab.url().isValid():
|
||||||
history_data = tab.history.serialize()
|
history_data = tab.history.serialize()
|
||||||
entry = UndoEntry(tab.cur_url, history_data)
|
entry = UndoEntry(tab.url(), history_data)
|
||||||
self._undo_stack.append(entry)
|
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
|
# There are some good reasons why a URL could be empty
|
||||||
# (target="_blank" with a download, see [1]), so we silently ignore
|
# (target="_blank" with a download, see [1]), so we silently ignore
|
||||||
# this.
|
# this.
|
||||||
@ -280,7 +280,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
# We display a warnings for URLs which are not empty but invalid -
|
# 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
|
# but we don't return here because we want the tab to close either
|
||||||
# way.
|
# 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()
|
tab.shutdown()
|
||||||
self.removeTab(idx)
|
self.removeTab(idx)
|
||||||
tab.deleteLater()
|
tab.deleteLater()
|
||||||
@ -298,7 +298,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
'startpage': QUrl(config.get('general', 'startpage')[0]),
|
'startpage': QUrl(config.get('general', 'startpage')[0]),
|
||||||
'default-page': config.get('general', 'default-page'),
|
'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('/')
|
last_close_urlstr = urls[last_close].toString().rstrip('/')
|
||||||
first_tab_urlstr = first_tab_url.toString().rstrip('/')
|
first_tab_urlstr = first_tab_url.toString().rstrip('/')
|
||||||
last_close_url_used = first_tab_urlstr == last_close_urlstr
|
last_close_url_used = first_tab_urlstr == last_close_urlstr
|
||||||
|
@ -116,7 +116,7 @@ class CrashHandler(QObject):
|
|||||||
window=win_id)
|
window=win_id)
|
||||||
for tab in tabbed_browser.widgets():
|
for tab in tabbed_browser.widgets():
|
||||||
try:
|
try:
|
||||||
urlstr = tab.cur_url.toString(
|
urlstr = tab.url().toString(
|
||||||
QUrl.RemovePassword | QUrl.FullyEncoded)
|
QUrl.RemovePassword | QUrl.FullyEncoded)
|
||||||
if urlstr:
|
if urlstr:
|
||||||
win_pages.append(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)
|
view = _mock_view_index(model, 0, 1, qtbot)
|
||||||
qtbot.add_widget(view)
|
qtbot.add_widget(view)
|
||||||
model.delete_cur_item(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'),
|
assert actual == [QUrl('https://github.com'),
|
||||||
QUrl('https://duckduckgo.com')]
|
QUrl('https://duckduckgo.com')]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user