Add a qt_version_check function to utils.misc.
We're usually only interested in the runtime version, not in the compile-time version, so we use this rather than comparing to QT_VERSION/PYQT_VERSION.
This commit is contained in:
parent
d76226626f
commit
43490202ca
@ -17,6 +17,8 @@
|
||||
|
||||
"""The main browser widgets."""
|
||||
|
||||
import operator
|
||||
|
||||
import sip
|
||||
from PyQt5.QtCore import QCoreApplication, pyqtSignal, pyqtSlot, PYQT_VERSION
|
||||
from PyQt5.QtNetwork import QNetworkReply
|
||||
|
@ -27,11 +27,12 @@ import re
|
||||
import sys
|
||||
import shlex
|
||||
import os.path
|
||||
import operator
|
||||
import urllib.request
|
||||
from urllib.parse import urljoin, urlencode
|
||||
from functools import reduce
|
||||
from distutils.version import StrictVersion as Version
|
||||
|
||||
from distutils.version import StrictVersion as Version
|
||||
from PyQt5.QtCore import QCoreApplication, QStandardPaths, QEventLoop, qVersion
|
||||
from PyQt5.QtGui import QColor
|
||||
from pkg_resources import resource_string
|
||||
@ -50,6 +51,16 @@ MINVALS = {
|
||||
}
|
||||
|
||||
|
||||
def qt_version_check(version, op=operator.ge):
|
||||
"""Check if the Qt runtime version is the version supplied or newer.
|
||||
|
||||
Args:
|
||||
version: The version to check against.
|
||||
op: The operator to use for the check.
|
||||
"""
|
||||
return op(Version(qVersion()), Version(version))
|
||||
|
||||
|
||||
def elide(text, length):
|
||||
"""Elide text so it uses a maximum of length chars."""
|
||||
if length < 1:
|
||||
@ -247,7 +258,7 @@ def actute_warning():
|
||||
return
|
||||
# Qt >= 5.3 doesn't seem to be affected
|
||||
try:
|
||||
if Version(qVersion()) >= Version('5.3.0'):
|
||||
if qt_version_check('5.3.0'):
|
||||
return
|
||||
except ValueError:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user