Add tab.new_tab_requested signal
This commit is contained in:
parent
4d650c8dfd
commit
86f63e1ae6
@ -386,6 +386,9 @@ class AbstractTab(QWidget):
|
||||
|
||||
Signals:
|
||||
See related Qt signals.
|
||||
|
||||
new_tab_requested: Emitted when a new tab should be opened with the
|
||||
given URL.
|
||||
"""
|
||||
|
||||
window_close_requested = pyqtSignal()
|
||||
@ -398,6 +401,7 @@ class AbstractTab(QWidget):
|
||||
url_text_changed = pyqtSignal(str)
|
||||
title_changed = pyqtSignal(str)
|
||||
load_status_changed = pyqtSignal(str)
|
||||
new_tab_requested = pyqtSignal(QUrl)
|
||||
shutting_down = pyqtSignal()
|
||||
|
||||
def __init__(self, win_id, parent=None):
|
||||
|
@ -284,8 +284,10 @@ class WebViewCaret(tab.AbstractCaret):
|
||||
except KeyError:
|
||||
raise tab.WebTabError('Anchor element without href!')
|
||||
url = self._tab.cur_url.resolved(QUrl(url))
|
||||
# FIXME(refactoring) does this open in a new tab?
|
||||
self._tab.openurl(url)
|
||||
if tab:
|
||||
self._tab.new_tab_requested.emit(url)
|
||||
else:
|
||||
self._tab.openurl(url)
|
||||
|
||||
|
||||
class WebViewZoom(tab.AbstractZoom):
|
||||
|
@ -205,6 +205,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
functools.partial(self.on_load_started, tab))
|
||||
tab.window_close_requested.connect(
|
||||
functools.partial(self.on_window_close_requested, tab))
|
||||
tab.new_tab_requested.connect(self.tabopen)
|
||||
|
||||
def current_url(self):
|
||||
"""Get the URL of the current tab.
|
||||
@ -347,6 +348,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
log.webview.debug("Requested to close {!r} which does not "
|
||||
"exist!".format(widget))
|
||||
|
||||
@pyqtSlot('QUrl')
|
||||
@pyqtSlot('QUrl', bool)
|
||||
def tabopen(self, url=None, background=None, explicit=False):
|
||||
"""Open a new tab with a given URL.
|
||||
|
Loading…
Reference in New Issue
Block a user