old qt: Simplify various version checks

This commit is contained in:
Florian Bruhin 2020-11-03 14:17:47 +01:00
parent af37cfe2e2
commit a14d0d433e
6 changed files with 16 additions and 35 deletions

View File

@ -284,9 +284,7 @@ def get_user_stylesheet(searching=False):
css += f.read()
setting = config.val.scrolling.bar
overlay_bar_available = (qtutils.version_check('5.11', compiled=False) and
not utils.is_mac)
if setting == 'overlay' and not overlay_bar_available:
if setting == 'overlay' and not utils.is_mac:
setting = 'when-searching'
if setting == 'never' or setting == 'when-searching' and not searching:

View File

@ -301,8 +301,7 @@ def _update_settings(option):
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-75884
# (note this isn't actually fixed properly before Qt 5.15)
header_bug_fixed = (not qtutils.version_check('5.12', compiled=False) or
qtutils.version_check('5.15', compiled=False))
header_bug_fixed = qtutils.version_check('5.15', compiled=False)
if option in ['content.headers.user_agent',
'content.headers.accept_language'] and header_bug_fixed:

View File

@ -1557,7 +1557,6 @@ class WebEngineTab(browsertab.AbstractTab):
"""
super()._on_load_progress(perc)
if (perc == 100 and
qtutils.version_check('5.10', compiled=False) and
self.load_status() != usertypes.LoadStatus.error):
self._update_load_status(ok=True)
@ -1610,8 +1609,7 @@ class WebEngineTab(browsertab.AbstractTab):
(qtutils.version_check('5.13') and
not qtutils.version_check('5.13.2')) or
(qtutils.version_check('5.12') and
not qtutils.version_check('5.12.6')) or
not qtutils.version_check('5.12')
not qtutils.version_check('5.12.6'))
)
)

View File

@ -93,7 +93,7 @@ def _qtwebengine_enabled_features(feature_flags: Sequence[str]) -> Iterator[str]
# just turn it on unconditionally on Linux, which shouldn't hurt.
yield 'WebRTCPipeWireCapturer'
if qtutils.version_check('5.11', compiled=False) and not utils.is_mac:
if not utils.is_mac:
# Enable overlay scrollbars.
#
# There are two additional flags in Chromium:
@ -118,13 +118,8 @@ def _qtwebengine_args(
is_qt_514 = (qtutils.version_check('5.14', compiled=False) and
not qtutils.version_check('5.15', compiled=False))
if not qtutils.version_check('5.11', compiled=False) or is_qt_514:
# WORKAROUND equivalent to
# https://codereview.qt-project.org/#/c/217932/
# Needed for Qt < 5.9.5 and < 5.10.1
#
# For Qt 5,14, WORKAROUND for
# https://bugreports.qt.io/browse/QTBUG-82105
if is_qt_514:
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-82105
yield '--disable-shared-workers'
# WORKAROUND equivalent to

View File

@ -140,8 +140,7 @@ def pytest_collection_modifyitems(config, items):
"""Apply @qtwebengine_* markers; skip unittests with QUTE_BDD_WEBENGINE."""
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-75884
# (note this isn't actually fixed properly before Qt 5.15)
header_bug_fixed = (not qtutils.version_check('5.12', compiled=False) or
qtutils.version_check('5.15', compiled=False))
header_bug_fixed = qtutils.version_check('5.15', compiled=False)
lib_path = pathlib.Path(QCoreApplication.libraryPaths()[0])
qpdf_image_plugin = lib_path / 'imageformats' / 'libqpdf.so'

View File

@ -42,8 +42,7 @@ class TestQtArgs:
@pytest.fixture(autouse=True)
def reduce_args(self, monkeypatch, config_stub):
"""Make sure no --disable-shared-workers/referer argument get added."""
monkeypatch.setattr(qtargs.qtutils, 'version_check',
lambda version, compiled=False: True)
monkeypatch.setattr(qtargs.qtutils, 'qVersion', lambda: '5.15.0')
config_stub.val.content.headers.referer = 'always'
@pytest.mark.parametrize('args, expected', [
@ -95,8 +94,7 @@ class TestQtArgs:
])
def test_shared_workers(self, config_stub, monkeypatch, parser,
backend, expected):
monkeypatch.setattr(qtargs.qtutils, 'version_check',
lambda version, compiled=False: False)
monkeypatch.setattr(qtargs.qtutils, 'qVersion', lambda: '5.14.0')
monkeypatch.setattr(qtargs.objects, 'backend', backend)
parsed = parser.parse_args([])
args = qtargs.qt_args(parsed)
@ -295,26 +293,20 @@ class TestQtArgs:
assert ('--force-dark-mode' in args) == added
@pytest.mark.parametrize('bar, new_qt, is_mac, added', [
@pytest.mark.parametrize('bar, is_mac, added', [
# Overlay bar enabled
('overlay', True, False, True),
('overlay', False, True),
# No overlay on mac
('overlay', True, True, False),
('overlay', False, True, False),
# No overlay on old Qt
('overlay', False, False, False),
('overlay', True, False),
# Overlay disabled
('when-searching', True, False, False),
('always', True, False, False),
('never', True, False, False),
('when-searching', False, False),
('always', False, False),
('never', False, False),
])
def test_overlay_scrollbar(self, config_stub, monkeypatch, parser,
bar, new_qt, is_mac, added):
bar, is_mac, added):
monkeypatch.setattr(qtargs.objects, 'backend',
usertypes.Backend.QtWebEngine)
monkeypatch.setattr(qtargs.qtutils, 'version_check',
lambda version, exact=False, compiled=True:
new_qt)
monkeypatch.setattr(qtargs.utils, 'is_mac', is_mac)
# Avoid WebRTC pipewire feature
monkeypatch.setattr(qtargs.utils, 'is_linux', False)