Switch browsing history away from QWebHistoryInterface.
Now adds a url to browser history once we have connected and got enough data to start rendering the page. The previous approach saved urls as soon as navigation was initiated, so upon encountering a redirect the final url wasn't saved. Using layout started rather than load finished means that pages whose contents manage to load minus one troublesome asset will still be saved.
This commit is contained in:
parent
1524f29f71
commit
33fbe97863
@ -212,4 +212,3 @@ def init(parent=None):
|
||||
"""
|
||||
history = WebHistory(parent)
|
||||
objreg.register('web-history', history)
|
||||
QWebHistoryInterface.setDefaultInterface(history)
|
||||
|
@ -145,6 +145,12 @@ class WebView(QWebView):
|
||||
self.loadProgress.connect(lambda p: setattr(self, 'progress', p))
|
||||
objreg.get('config').changed.connect(self.on_config_changed)
|
||||
|
||||
@pyqtSlot()
|
||||
def on_initial_layout_complete(self):
|
||||
"""Add url to history now that we have displayed something."""
|
||||
objreg.get('web-history').addHistoryEntry(
|
||||
self.url().toDisplayString(), self.title())
|
||||
|
||||
def _init_page(self):
|
||||
"""Initialize the QWebPage used by this view."""
|
||||
page = webpage.BrowserPage(self.win_id, self.tab_id, self)
|
||||
@ -152,6 +158,8 @@ class WebView(QWebView):
|
||||
page.linkHovered.connect(self.linkHovered)
|
||||
page.mainFrame().loadStarted.connect(self.on_load_started)
|
||||
page.mainFrame().loadFinished.connect(self.on_load_finished)
|
||||
page.mainFrame().initialLayoutCompleted.connect(
|
||||
self.on_initial_layout_complete)
|
||||
page.statusBarMessage.connect(
|
||||
lambda msg: setattr(self, 'statusbar_message', msg))
|
||||
page.networkAccessManager().sslErrors.connect(
|
||||
|
Loading…
Reference in New Issue
Block a user