Add ui.modal-js-dialog to restore the default JS dialogs

This commit is contained in:
Martin Tournoij 2015-05-31 21:32:16 +02:00
parent 1e5c67f152
commit 4204a8de9a
3 changed files with 11 additions and 0 deletions

View File

@ -45,6 +45,7 @@
|<<ui-hide-statusbar,hide-statusbar>>|Whether to hide the statusbar unless a message is shown. |<<ui-hide-statusbar,hide-statusbar>>|Whether to hide the statusbar unless a message is shown.
|<<ui-window-title-format,window-title-format>>|The format to use for the window title. The following placeholders are defined: |<<ui-window-title-format,window-title-format>>|The format to use for the window title. The following placeholders are defined:
|<<ui-hide-mouse-cursor,hide-mouse-cursor>>|Whether to hide the mouse cursor. |<<ui-hide-mouse-cursor,hide-mouse-cursor>>|Whether to hide the mouse cursor.
|<<ui-model-js-dialog,modal-js-dialog>>|Use standard JavaScript modal dialog for alert() and confirm()
|============== |==============
.Quick reference for section ``network'' .Quick reference for section ``network''

View File

@ -481,6 +481,9 @@ class BrowserPage(QWebPage):
def javaScriptAlert(self, _frame, msg): def javaScriptAlert(self, _frame, msg):
"""Override javaScriptAlert to use the statusbar.""" """Override javaScriptAlert to use the statusbar."""
log.js.debug("alert: {}".format(msg)) log.js.debug("alert: {}".format(msg))
if config.get('ui', 'modal-js-dialog'):
return super().javaScriptAlert(_frame, msg)
if (self._is_shutting_down or if (self._is_shutting_down or
config.get('content', 'ignore-javascript-alert')): config.get('content', 'ignore-javascript-alert')):
return return
@ -489,6 +492,9 @@ class BrowserPage(QWebPage):
def javaScriptConfirm(self, _frame, msg): def javaScriptConfirm(self, _frame, msg):
"""Override javaScriptConfirm to use the statusbar.""" """Override javaScriptConfirm to use the statusbar."""
log.js.debug("confirm: {}".format(msg)) log.js.debug("confirm: {}".format(msg))
if config.get('ui', 'modal-js-dialog'):
return super().javaScriptConfirm(_frame, msg)
if self._is_shutting_down: if self._is_shutting_down:
return False return False
ans = self._ask("[js confirm] {}".format(msg), ans = self._ask("[js confirm] {}".format(msg),

View File

@ -305,6 +305,10 @@ def data(readonly=False):
SettingValue(typ.Bool(), 'false'), SettingValue(typ.Bool(), 'false'),
"Whether to hide the mouse cursor."), "Whether to hide the mouse cursor."),
('modal-js-dialog',
SettingValue(typ.Bool(), 'false'),
"Use standard JavaScript modal dialog for alert() and confirm()"),
readonly=readonly readonly=readonly
)), )),