From 4204a8de9a19fefb8098422a291dcbe6495e6580 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Sun, 31 May 2015 21:32:16 +0200 Subject: [PATCH 1/4] Add ui.modal-js-dialog to restore the default JS dialogs --- doc/help/settings.asciidoc | 1 + qutebrowser/browser/webpage.py | 6 ++++++ qutebrowser/config/configdata.py | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index d3c571aa3..4886d9dcd 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -45,6 +45,7 @@ |<>|Whether to hide the statusbar unless a message is shown. |<>|The format to use for the window title. The following placeholders are defined: |<>|Whether to hide the mouse cursor. +|<>|Use standard JavaScript modal dialog for alert() and confirm() |============== .Quick reference for section ``network'' diff --git a/qutebrowser/browser/webpage.py b/qutebrowser/browser/webpage.py index 005a6e300..fd6e7a7c9 100644 --- a/qutebrowser/browser/webpage.py +++ b/qutebrowser/browser/webpage.py @@ -481,6 +481,9 @@ class BrowserPage(QWebPage): def javaScriptAlert(self, _frame, msg): """Override javaScriptAlert to use the statusbar.""" log.js.debug("alert: {}".format(msg)) + if config.get('ui', 'modal-js-dialog'): + return super().javaScriptAlert(_frame, msg) + if (self._is_shutting_down or config.get('content', 'ignore-javascript-alert')): return @@ -489,6 +492,9 @@ class BrowserPage(QWebPage): def javaScriptConfirm(self, _frame, msg): """Override javaScriptConfirm to use the statusbar.""" log.js.debug("confirm: {}".format(msg)) + if config.get('ui', 'modal-js-dialog'): + return super().javaScriptConfirm(_frame, msg) + if self._is_shutting_down: return False ans = self._ask("[js confirm] {}".format(msg), diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 02b8c6008..f2c68c708 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -305,6 +305,10 @@ def data(readonly=False): SettingValue(typ.Bool(), 'false'), "Whether to hide the mouse cursor."), + ('modal-js-dialog', + SettingValue(typ.Bool(), 'false'), + "Use standard JavaScript modal dialog for alert() and confirm()"), + readonly=readonly )), From e7619477cd341fdefaf22af29095b2fa9cef7de3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 31 May 2015 21:40:19 +0200 Subject: [PATCH 2/4] Rename _frame argument to frame. _foo is used to denote unused arguments, so renaming this as it's now used. --- qutebrowser/browser/webpage.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/webpage.py b/qutebrowser/browser/webpage.py index fd6e7a7c9..8e430efcb 100644 --- a/qutebrowser/browser/webpage.py +++ b/qutebrowser/browser/webpage.py @@ -478,22 +478,22 @@ class BrowserPage(QWebPage): return super().extension(ext, opt, out) return handler(opt, out) - def javaScriptAlert(self, _frame, msg): + def javaScriptAlert(self, frame, msg): """Override javaScriptAlert to use the statusbar.""" log.js.debug("alert: {}".format(msg)) if config.get('ui', 'modal-js-dialog'): - return super().javaScriptAlert(_frame, msg) + return super().javaScriptAlert(frame, msg) if (self._is_shutting_down or config.get('content', 'ignore-javascript-alert')): return self._ask("[js alert] {}".format(msg), usertypes.PromptMode.alert) - def javaScriptConfirm(self, _frame, msg): + def javaScriptConfirm(self, frame, msg): """Override javaScriptConfirm to use the statusbar.""" log.js.debug("confirm: {}".format(msg)) if config.get('ui', 'modal-js-dialog'): - return super().javaScriptConfirm(_frame, msg) + return super().javaScriptConfirm(frame, msg) if self._is_shutting_down: return False From f52f3db1f21a55509d06b17677dfff2d5b2ad379 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 31 May 2015 21:41:32 +0200 Subject: [PATCH 3/4] Regenerate docs. --- README.asciidoc | 2 +- doc/help/settings.asciidoc | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index a1d4c2128..63d803d8f 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -141,8 +141,8 @@ Contributors, sorted by the number of commits in descending order: * Artur Shaik * Antoni Boucher * ZDarian -* Peter Vilim * Martin Tournoij +* Peter Vilim * John ShaggyTwoDope Jenkins * Jimmy * Zach-Button diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 4886d9dcd..073ad2d63 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -45,7 +45,7 @@ |<>|Whether to hide the statusbar unless a message is shown. |<>|The format to use for the window title. The following placeholders are defined: |<>|Whether to hide the mouse cursor. -|<>|Use standard JavaScript modal dialog for alert() and confirm() +|<>|Use standard JavaScript modal dialog for alert() and confirm() |============== .Quick reference for section ``network'' @@ -595,6 +595,17 @@ Valid values: Default: +pass:[false]+ +[[ui-modal-js-dialog]] +=== modal-js-dialog +Use standard JavaScript modal dialog for alert() and confirm() + +Valid values: + + * +true+ + * +false+ + +Default: +pass:[false]+ + == network Settings related to the network. From a14685be3de0609de196bdb47856a22a7da4097e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 31 May 2015 21:42:25 +0200 Subject: [PATCH 4/4] Update changelog. --- CHANGELOG.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 8c994280f..96e6482ea 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -36,6 +36,7 @@ Added - New arguments `--top-navigate` and `--bottom-navigate` (`-t`/`-b`) for `:scroll-page` to specify a navigation action (e.g. automatically go to the next page when arriving at the bottom). - New flag `-d`/`--detach` for `:spawn` to detach the spawned process so it's not closed when qutebrowser is. - New (hidden) command `:follow-selected` (bound to `Enter`/`Ctrl-Enter` by default) to follow the link which is currently selected (e.g. after searching via `/`). +- New setting `ui -> modal-js-dialog` to use the standard modal dialogs for javascript questions instead of using the statusbar. Changed ~~~~~~~