From 71f7b01ea7200a9a5786c76677ecd2ada1ff5d18 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 21 Feb 2017 19:25:18 +0100 Subject: [PATCH] Bring back PyQt (but not Qt) 5.7.0 support with QtWebEngine This was originally removed in a86170f45, however Debian testing (Stretch) comes with Qt 5.7.1, but PyQt 5.7. --- CHANGELOG.asciidoc | 2 +- qutebrowser/browser/webengine/webview.py | 24 ++++++++++++++---------- qutebrowser/misc/earlyinit.py | 4 ++-- tests/conftest.py | 8 ++++++-- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 255f4585d..381d20842 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -37,7 +37,7 @@ Added Changed ~~~~~~~ -- PyQt/Qt 5.7.1 is now required for the QtWebEngine backend +- PyQt 5.7/Qt 5.7.1 is now required for the QtWebEngine backend - Scrolling with the scrollwheel while holding shift now scrolls sideways - New way of clicking hints with which solves various small issues - When yanking a mailto: link via hints, the mailto: prefix is now stripped diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py index a6bdb12f4..4d6c57f8e 100644 --- a/qutebrowser/browser/webengine/webview.py +++ b/qutebrowser/browser/webengine/webview.py @@ -244,16 +244,20 @@ class WebEnginePage(QWebEnginePage): except shared.CallSuper: return super().javaScriptConfirm(url, js_msg) - def javaScriptPrompt(self, url, js_msg, default): - """Override javaScriptPrompt to use qutebrowser prompts.""" - if self._is_shutting_down: - return (False, "") - try: - return shared.javascript_prompt(url, js_msg, default, - abort_on=[self.loadStarted, - self.shutting_down]) - except shared.CallSuper: - return super().javaScriptPrompt(url, js_msg, default) + if PYQT_VERSION > 0x050700: + # WORKAROUND + # Can't override javaScriptPrompt with older PyQt versions + # https://www.riverbankcomputing.com/pipermail/pyqt/2016-November/038293.html + def javaScriptPrompt(self, url, js_msg, default): + """Override javaScriptPrompt to use qutebrowser prompts.""" + if self._is_shutting_down: + return (False, "") + try: + return shared.javascript_prompt(url, js_msg, default, + abort_on=[self.loadStarted, + self.shutting_down]) + except shared.CallSuper: + return super().javaScriptPrompt(url, js_msg, default) def javaScriptAlert(self, url, js_msg): """Override javaScriptAlert to use qutebrowser prompts.""" diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py index e84f04f7f..015e89851 100644 --- a/qutebrowser/misc/earlyinit.py +++ b/qutebrowser/misc/earlyinit.py @@ -271,8 +271,8 @@ def check_qt_version(backend): _die(text) elif (backend == 'webengine' and ( qtutils.version_check('5.7.0', operator.lt) or - PYQT_VERSION < 0x050701)): - text = ("Fatal error: Qt and PyQt >= 5.7.1 are required for " + PYQT_VERSION < 0x050700)): + text = ("Fatal error: Qt >= 5.7.1 and PyQt >= 5.7 are required for " "QtWebEngine support, but Qt {} / PyQt {} is installed." .format(qVersion(), PYQT_VERSION_STR)) _die(text) diff --git a/tests/conftest.py b/tests/conftest.py index f782e810e..8b040361d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -120,9 +120,13 @@ def pytest_collection_modifyitems(config, items): _apply_platform_markers(item) if item.get_marker('xfail_norun'): item.add_marker(pytest.mark.xfail(run=False)) - if item.get_marker('js_prompt') and not config.webengine: + if item.get_marker('js_prompt'): + if config.webengine: + js_prompt_pyqt_version = 0x050700 + else: + js_prompt_pyqt_version = 0x050300 item.add_marker(pytest.mark.skipif( - PYQT_VERSION <= 0x050300, + PYQT_VERSION <= js_prompt_pyqt_version, reason='JS prompts are not supported with this PyQt version')) if deselected: