Don't set an URL for :view-source tabs
Otherwise the page URL gets added to the history again with QtWebKit.
This commit is contained in:
parent
f2d3d78b12
commit
920dde4a68
@ -793,7 +793,7 @@ class AbstractTab(QWidget):
|
||||
def icon(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def set_html(self, html, base_url):
|
||||
def set_html(self, html, base_url=QUrl()):
|
||||
raise NotImplementedError
|
||||
|
||||
def networkaccessmanager(self):
|
||||
|
@ -1375,13 +1375,8 @@ class CommandDispatcher:
|
||||
formatter = pygments.formatters.HtmlFormatter(full=True,
|
||||
linenos='table')
|
||||
highlighted = pygments.highlight(source, lexer, formatter)
|
||||
try:
|
||||
current_url = self._current_url()
|
||||
except cmdexc.CommandError as e:
|
||||
message.error(str(e))
|
||||
return
|
||||
new_tab = self._tabbed_browser.tabopen()
|
||||
new_tab.set_html(highlighted, current_url)
|
||||
new_tab.set_html(highlighted)
|
||||
new_tab.data.viewing_source = True
|
||||
|
||||
tab.dump_async(show_source_cb)
|
||||
|
@ -257,6 +257,10 @@ class WebHistory(QObject):
|
||||
@pyqtSlot(QUrl, QUrl, str)
|
||||
def add_from_tab(self, url, requested_url, title):
|
||||
"""Add a new history entry as slot, called from a BrowserTab."""
|
||||
if url.isEmpty():
|
||||
# things set via setHtml
|
||||
return
|
||||
|
||||
no_formatting = QUrl.UrlFormattingOption(0)
|
||||
if (requested_url.isValid() and
|
||||
not requested_url.matches(url, no_formatting)):
|
||||
|
@ -626,14 +626,12 @@ class WebEngineTab(browsertab.AbstractTab):
|
||||
def icon(self):
|
||||
return self._widget.icon()
|
||||
|
||||
def set_html(self, html, base_url=None):
|
||||
def set_html(self, html, base_url=QUrl()):
|
||||
# FIXME:qtwebengine
|
||||
# check this and raise an exception if too big:
|
||||
# Warning: The content will be percent encoded before being sent to the
|
||||
# renderer via IPC. This may increase its size. The maximum size of the
|
||||
# percent encoded content is 2 megabytes minus 30 bytes.
|
||||
if base_url is None:
|
||||
base_url = QUrl()
|
||||
self._widget.setHtml(html, base_url)
|
||||
|
||||
def networkaccessmanager(self):
|
||||
|
@ -710,7 +710,7 @@ class WebKitTab(browsertab.AbstractTab):
|
||||
requested_url = self.url(requested=True)
|
||||
self.add_history_item.emit(url, requested_url, self.title())
|
||||
|
||||
def set_html(self, html, base_url):
|
||||
def set_html(self, html, base_url=QUrl()):
|
||||
self._widget.setHtml(html, base_url)
|
||||
|
||||
def networkaccessmanager(self):
|
||||
|
Loading…
Reference in New Issue
Block a user