AddonManager: Adapt to Qt6/PySide6

QtNetwork.QNetworkRequest has a small API change that is addressed in
this commit.
This commit is contained in:
Pieter Hijma
2024-05-18 22:13:08 +02:00
committed by Chris Hennes
parent ff17df2ff5
commit cb8da09e27

View File

@@ -104,7 +104,17 @@ if HAVE_QTNETWORK:
# Added in Qt 5.15
if hasattr(QtNetwork.QNetworkRequest, "DefaultTransferTimeoutConstant"):
default_timeout = QtNetwork.QNetworkRequest.DefaultTransferTimeoutConstant
timeoutConstant = QtNetwork.QNetworkRequest.DefaultTransferTimeoutConstant
if hasattr(timeoutConstant, "value"):
# Qt 6 changed the timeout constant to have a 'value' attribute.
# The function setTransferTimeout does not accept
# DefaultTransferTimeoutConstant of type
# QtNetwork.QNetworkRequest.TransferTimeoutConstant any
# longer but only an int.
default_timeout = timeoutConstant.value
else:
# In Qt 5.15 we can use the timeoutConstant as is.
default_timeout = timeoutConstant
else:
default_timeout = 30000
@@ -428,6 +438,11 @@ if HAVE_QTNETWORK:
)
if hasattr(request, "setTransferTimeout"):
# Added in Qt 5.15
# In Qt 5, the function setTransferTimeout seems to accept
# DefaultTransferTimeoutConstant of type
# PySide2.QtNetwork.QNetworkRequest.TransferTimeoutConstant,
# whereas in Qt 6, the function seems to only accept an
# integer.
request.setTransferTimeout(timeout_ms)
return request