Move 'progress' to AbstractTab
This makes load progress work with QtWebEngine.
This commit is contained in:
parent
8567fffdad
commit
6ae232d8fc
@ -466,6 +466,7 @@ class AbstractTab(QWidget):
|
||||
self.data = TabData()
|
||||
self._layout = None
|
||||
self._widget = None
|
||||
self._progress = 0
|
||||
self.backend = None
|
||||
|
||||
def _set_widget(self, widget):
|
||||
@ -483,14 +484,20 @@ class AbstractTab(QWidget):
|
||||
|
||||
@pyqtSlot()
|
||||
def _on_load_started(self):
|
||||
self._progress = 0
|
||||
self.data.viewing_source = False
|
||||
self.load_started.emit()
|
||||
|
||||
@pyqtSlot(int)
|
||||
def _on_load_progress(self, perc):
|
||||
self._progress = perc
|
||||
self.load_progress.emit(perc)
|
||||
|
||||
def url(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def progress(self):
|
||||
raise NotImplementedError
|
||||
return self._progress
|
||||
|
||||
def load_status(self):
|
||||
raise NotImplementedError
|
||||
|
@ -266,10 +266,6 @@ class WebEngineTab(browsertab.AbstractTab):
|
||||
def url(self):
|
||||
return self._widget.url()
|
||||
|
||||
def progress(self):
|
||||
log.stub()
|
||||
return 0
|
||||
|
||||
def load_status(self):
|
||||
log.stub()
|
||||
return usertypes.LoadStatus.success
|
||||
@ -321,7 +317,7 @@ class WebEngineTab(browsertab.AbstractTab):
|
||||
page = view.page()
|
||||
page.windowCloseRequested.connect(self.window_close_requested)
|
||||
page.linkHovered.connect(self.link_hovered)
|
||||
page.loadProgress.connect(self.load_progress)
|
||||
page.loadProgress.connect(self._on_load_progress)
|
||||
page.loadStarted.connect(self._on_load_started)
|
||||
view.titleChanged.connect(self.title_changed)
|
||||
page.loadFinished.connect(self.load_finished)
|
||||
|
@ -472,9 +472,6 @@ class WebKitTab(browsertab.AbstractTab):
|
||||
def url(self):
|
||||
return self._widget.cur_url
|
||||
|
||||
def progress(self):
|
||||
return self._widget.progress
|
||||
|
||||
def load_status(self):
|
||||
return self._widget.load_status
|
||||
|
||||
@ -522,7 +519,7 @@ class WebKitTab(browsertab.AbstractTab):
|
||||
frame = page.mainFrame()
|
||||
page.windowCloseRequested.connect(self.window_close_requested)
|
||||
page.linkHovered.connect(self.link_hovered)
|
||||
page.loadProgress.connect(self.load_progress)
|
||||
page.loadProgress.connect(self._on_load_progress)
|
||||
frame.loadStarted.connect(self._on_load_started)
|
||||
view.scroll_pos_changed.connect(self.scroll.perc_changed)
|
||||
view.titleChanged.connect(self.title_changed)
|
||||
|
@ -41,7 +41,6 @@ class WebView(QWebView):
|
||||
Attributes:
|
||||
tab: The WebKitTab object for this WebView
|
||||
hintmanager: The HintManager instance for this view.
|
||||
progress: loading progress of this page.
|
||||
scroll_pos: The current scroll position as (x%, y%) tuple.
|
||||
statusbar_message: The current javascript statusbar message.
|
||||
load_status: loading status of this page (index into LoadStatus)
|
||||
@ -91,7 +90,6 @@ class WebView(QWebView):
|
||||
self._ignore_wheel_event = False
|
||||
self._set_bg_color()
|
||||
self.cur_url = QUrl()
|
||||
self.progress = 0
|
||||
self._tab_id = tab_id
|
||||
|
||||
page = self._init_page()
|
||||
@ -108,7 +106,6 @@ class WebView(QWebView):
|
||||
if config.get('input', 'rocker-gestures'):
|
||||
self.setContextMenuPolicy(Qt.PreventContextMenu)
|
||||
self.urlChanged.connect(self.on_url_changed)
|
||||
self.loadProgress.connect(lambda p: setattr(self, 'progress', p))
|
||||
objreg.get('config').changed.connect(self.on_config_changed)
|
||||
|
||||
@pyqtSlot()
|
||||
@ -355,7 +352,6 @@ class WebView(QWebView):
|
||||
@pyqtSlot()
|
||||
def on_load_started(self):
|
||||
"""Leave insert/hint mode and set vars when a new page is loading."""
|
||||
self.progress = 0
|
||||
self._has_ssl_errors = False
|
||||
self._set_load_status(usertypes.LoadStatus.loading)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user