remove QT4 references

This commit is contained in:
andrea reale
2022-03-03 16:13:15 +01:00
committed by wmayer
parent b25eaec2e5
commit 83d3a916c0
15 changed files with 17 additions and 119 deletions

View File

@@ -38,10 +38,6 @@ import six
Qtranslate = QtCore.QCoreApplication.translate
# This property only exists in Qt4, which is normally paired
# with Python 2.
# But if Python 2 is used with Qt5 (rare),
# this assignment will fail.
try:
_encoding = QtGui.QApplication.UnicodeUTF8
except AttributeError:
@@ -115,35 +111,7 @@ def translate(context, text, utf8_decode=False):
# the translate function doesn't use the 4th parameter
if six.PY3:
return Qtranslate(context, text, None)
# Python 2
elif QtCore.qVersion() > "4":
# Python 2 and Qt5
if utf8_decode:
# The text is a utf8 string, and since it is Qt5
# the translate function doesn't use the 4th parameter
return Qtranslate(context, text, None)
else:
# The text is not a unicode string, and since it is Qt5
# the translate function doesn't use the 4th parameter.
# Therefore the output string needs to be encoded manually
# as utf8 bytes before returning.
return Qtranslate(context, text, None).encode("utf8")
else:
# Python 2 and Qt4
if utf8_decode:
# The text is a utf8 string, and since it is Qt4
# the translate function uses the 4th parameter
# to handle the input encoding.
return Qtranslate(context, text, None, _encoding)
else:
# The text is not a unicode string, and since it is Qt4
# the translate function uses the 4th parameter
# to handle the encoding.
# In this case, the `encoding` is `None`, therefore
# the output string needs to be encoded manually
# as utf8 bytes before returning.
return Qtranslate(context, text, None, _encoding).encode("utf8")
# Original code no longer used. It is listed here for reference
# to show how the different pairings Py2/Qt4, Py3/Qt5, Py2/Qt5, Py3/Qt4