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.
This commit is contained in:
Florian Bruhin 2017-02-21 19:25:18 +01:00
parent a179d6a738
commit 71f7b01ea7
4 changed files with 23 additions and 15 deletions

View File

@ -37,7 +37,7 @@ Added
Changed 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 - Scrolling with the scrollwheel while holding shift now scrolls sideways
- New way of clicking hints with which solves various small issues - New way of clicking hints with which solves various small issues
- When yanking a mailto: link via hints, the mailto: prefix is now stripped - When yanking a mailto: link via hints, the mailto: prefix is now stripped

View File

@ -244,16 +244,20 @@ class WebEnginePage(QWebEnginePage):
except shared.CallSuper: except shared.CallSuper:
return super().javaScriptConfirm(url, js_msg) return super().javaScriptConfirm(url, js_msg)
def javaScriptPrompt(self, url, js_msg, default): if PYQT_VERSION > 0x050700:
"""Override javaScriptPrompt to use qutebrowser prompts.""" # WORKAROUND
if self._is_shutting_down: # Can't override javaScriptPrompt with older PyQt versions
return (False, "") # https://www.riverbankcomputing.com/pipermail/pyqt/2016-November/038293.html
try: def javaScriptPrompt(self, url, js_msg, default):
return shared.javascript_prompt(url, js_msg, default, """Override javaScriptPrompt to use qutebrowser prompts."""
abort_on=[self.loadStarted, if self._is_shutting_down:
self.shutting_down]) return (False, "")
except shared.CallSuper: try:
return super().javaScriptPrompt(url, js_msg, default) 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): def javaScriptAlert(self, url, js_msg):
"""Override javaScriptAlert to use qutebrowser prompts.""" """Override javaScriptAlert to use qutebrowser prompts."""

View File

@ -271,8 +271,8 @@ def check_qt_version(backend):
_die(text) _die(text)
elif (backend == 'webengine' and ( elif (backend == 'webengine' and (
qtutils.version_check('5.7.0', operator.lt) or qtutils.version_check('5.7.0', operator.lt) or
PYQT_VERSION < 0x050701)): PYQT_VERSION < 0x050700)):
text = ("Fatal error: Qt and PyQt >= 5.7.1 are required for " text = ("Fatal error: Qt >= 5.7.1 and PyQt >= 5.7 are required for "
"QtWebEngine support, but Qt {} / PyQt {} is installed." "QtWebEngine support, but Qt {} / PyQt {} is installed."
.format(qVersion(), PYQT_VERSION_STR)) .format(qVersion(), PYQT_VERSION_STR))
_die(text) _die(text)

View File

@ -120,9 +120,13 @@ def pytest_collection_modifyitems(config, items):
_apply_platform_markers(item) _apply_platform_markers(item)
if item.get_marker('xfail_norun'): if item.get_marker('xfail_norun'):
item.add_marker(pytest.mark.xfail(run=False)) 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( 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')) reason='JS prompts are not supported with this PyQt version'))
if deselected: if deselected: