Add window-open-behaviour setting

This commit is contained in:
Florian Bruhin 2014-05-08 20:43:40 +02:00
parent 4eb6f896b0
commit bf19cb7536
3 changed files with 20 additions and 1 deletions

View File

@ -807,3 +807,12 @@ class AcceptCookies(String):
valid_values = ValidValues(('default', "Default QtWebKit behaviour"),
('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)."))

View File

@ -191,6 +191,11 @@ DATA = OrderedDict([
SettingValue(types.Bool(), 'false'),
"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',
SettingValue(types.ShellCommand(placeholder=True), 'gvim -f "{}"'),
"The editor (and arguments) to use for the open_editor binding. "

View File

@ -286,7 +286,12 @@ class WebView(QWebView):
if wintype == QWebPage.WebModalDialog:
logging.warn("WebModalDialog requested, but we don't support "
"that!")
return self.tabbedbrowser.tabopen()
if config.get('general', 'window-open-behaviour') == 'new-tab':
return self.tabbedbrowser.tabopen()
else:
# FIXME for some odd reason, the history of the tab gets killed
# here...
return self
def paintEvent(self, e):
"""Extend paintEvent to emit a signal if the scroll position changed.