Save redirect links that are clicked on to history.

This allows webkit to color links that are clicked on but never rendered as
visited too. It also means if you get redirected from eg http://site.com to
http://site.com/ you have essentially duplicates in your history. This makes
the history completion a bit noisier. I suppose normalising paths before
checking for duplicates might help. Also note that otter has an isTypedIn flag
which might be used for dealing with this.
This commit is contained in:
Jimmy 2016-04-04 18:06:46 +12:00
parent b48b36a88d
commit cd21f6326e

View File

@ -119,6 +119,7 @@ class WebView(QWebView):
self.destroyed.connect(functools.partial(
cfg.changed.disconnect, self.init_neighborlist))
self.cur_url = QUrl()
self._orig_url = QUrl()
self.progress = 0
self.registry = objreg.ObjectRegistry()
self.tab_id = next(tab_id_gen)
@ -148,8 +149,13 @@ class WebView(QWebView):
@pyqtSlot()
def on_initial_layout_completed(self):
"""Add url to history now that we have displayed something."""
objreg.get('web-history').add_url(
self.url().toDisplayString(), self.title())
history = objreg.get('web-history')
if not self._orig_url.matches(self.cur_url,
QUrl.UrlFormattingOption(0)):
# If the url of the page is different than the url of the link
# originally clicked, save them both.
history.add_url(self._orig_url.toDisplayString())
history.add_url(self.cur_url.toDisplayString(), self.title())
def _init_page(self):
"""Initialize the QWebPage used by this view."""
@ -190,6 +196,8 @@ class WebView(QWebView):
log.webview.debug("load status for {}: {}".format(repr(self), val))
self.load_status = val
self.load_status_changed.emit(val.name)
if val == LoadStatus.loading:
self._orig_url = self.cur_url
def _set_bg_color(self):
"""Set the webpage background color as configured."""