Add window-open-behaviour setting
This commit is contained in:
parent
4eb6f896b0
commit
bf19cb7536
@ -807,3 +807,12 @@ class AcceptCookies(String):
|
|||||||
|
|
||||||
valid_values = ValidValues(('default', "Default QtWebKit behaviour"),
|
valid_values = ValidValues(('default', "Default QtWebKit behaviour"),
|
||||||
('never', "Don't accept cookies at all."))
|
('never', "Don't accept cookies at all."))
|
||||||
|
|
||||||
|
|
||||||
|
class WindowOpenBehaviour(String):
|
||||||
|
|
||||||
|
"""What to do when a webview requests a new window."""
|
||||||
|
|
||||||
|
valid_values = ValidValues(('same-tab', "Open new window in same tab."),
|
||||||
|
('new-tab', "Open new window in new tab (note: "
|
||||||
|
"history will be cleared)."))
|
||||||
|
@ -191,6 +191,11 @@ DATA = OrderedDict([
|
|||||||
SettingValue(types.Bool(), 'false'),
|
SettingValue(types.Bool(), 'false'),
|
||||||
"Whether to open new tabs (middleclick/ctrl+click) in background"),
|
"Whether to open new tabs (middleclick/ctrl+click) in background"),
|
||||||
|
|
||||||
|
('window-open-behaviour',
|
||||||
|
SettingValue(types.WindowOpenBehaviour(), 'new-tab'),
|
||||||
|
"What to do when the WebView requests a new window to be opened "
|
||||||
|
"(e.g. via javascript)"),
|
||||||
|
|
||||||
('editor',
|
('editor',
|
||||||
SettingValue(types.ShellCommand(placeholder=True), 'gvim -f "{}"'),
|
SettingValue(types.ShellCommand(placeholder=True), 'gvim -f "{}"'),
|
||||||
"The editor (and arguments) to use for the open_editor binding. "
|
"The editor (and arguments) to use for the open_editor binding. "
|
||||||
|
@ -286,7 +286,12 @@ class WebView(QWebView):
|
|||||||
if wintype == QWebPage.WebModalDialog:
|
if wintype == QWebPage.WebModalDialog:
|
||||||
logging.warn("WebModalDialog requested, but we don't support "
|
logging.warn("WebModalDialog requested, but we don't support "
|
||||||
"that!")
|
"that!")
|
||||||
|
if config.get('general', 'window-open-behaviour') == 'new-tab':
|
||||||
return self.tabbedbrowser.tabopen()
|
return self.tabbedbrowser.tabopen()
|
||||||
|
else:
|
||||||
|
# FIXME for some odd reason, the history of the tab gets killed
|
||||||
|
# here...
|
||||||
|
return self
|
||||||
|
|
||||||
def paintEvent(self, e):
|
def paintEvent(self, e):
|
||||||
"""Extend paintEvent to emit a signal if the scroll position changed.
|
"""Extend paintEvent to emit a signal if the scroll position changed.
|
||||||
|
Loading…
Reference in New Issue
Block a user