mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-16 18:59:39 +08:00
Qt5->Qt6: More renamed stuff.
part of CURA-8591
This commit is contained in:
parent
97da0b9183
commit
20b435af76
@ -13,7 +13,7 @@ class CameraAnimation(QVariantAnimation):
|
||||
super().__init__(parent)
|
||||
self._camera_tool = None
|
||||
self.setDuration(300)
|
||||
self.setEasingCurve(QEasingCurve.OutQuad)
|
||||
self.setEasingCurve(QEasingCurve.Type.OutQuad)
|
||||
|
||||
def setCameraTool(self, camera_tool):
|
||||
self._camera_tool = camera_tool
|
||||
|
@ -161,7 +161,7 @@ class CrashHandler:
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile( path ))
|
||||
|
||||
def _showDetailedReport(self):
|
||||
self.dialog.exec_()
|
||||
self.dialog.exec()
|
||||
|
||||
def _createDialog(self):
|
||||
"""Creates a modal dialog."""
|
||||
@ -449,5 +449,5 @@ class CrashHandler:
|
||||
def _show(self):
|
||||
# When the exception is in the skip_exception_types list, the dialog is not created, so we don't need to show it
|
||||
if self.dialog:
|
||||
self.dialog.exec_()
|
||||
self.dialog.exec()
|
||||
os._exit(1)
|
||||
|
@ -870,7 +870,7 @@ class CuraApplication(QtApplication):
|
||||
self._auto_save = AutoSave(self)
|
||||
self._auto_save.initialize()
|
||||
|
||||
self.exec_()
|
||||
self.exec()
|
||||
|
||||
def __setUpSingleInstanceServer(self):
|
||||
if self._use_single_instance:
|
||||
|
@ -8,7 +8,7 @@ from typing import Tuple
|
||||
|
||||
class PrintJobPreviewImageProvider(QQuickImageProvider):
|
||||
def __init__(self):
|
||||
super().__init__(QQuickImageProvider.Image)
|
||||
super().__init__(QQuickImageProvider.ImageType.Image)
|
||||
|
||||
def requestImage(self, id: str, size: QSize) -> Tuple[QImage, QSize]:
|
||||
"""Request a new image.
|
||||
|
@ -146,8 +146,8 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
||||
url = QUrl("http://" + self._address + self._api_prefix + target)
|
||||
request = QNetworkRequest(url)
|
||||
if content_type is not None:
|
||||
request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
||||
request.setHeader(QNetworkRequest.UserAgentHeader, self._user_agent)
|
||||
request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, content_type)
|
||||
request.setHeader(QNetworkRequest.KnownHeaders.UserAgentHeader, self._user_agent)
|
||||
return request
|
||||
|
||||
def createFormPart(self, content_header: str, data: bytes, content_type: Optional[str] = None) -> QHttpPart:
|
||||
@ -162,10 +162,10 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
||||
|
||||
if not content_header.startswith("form-data;"):
|
||||
content_header = "form-data; " + content_header
|
||||
part.setHeader(QNetworkRequest.ContentDispositionHeader, content_header)
|
||||
part.setHeader(QNetworkRequest.KnownHeaders.ContentDispositionHeader, content_header)
|
||||
|
||||
if content_type is not None:
|
||||
part.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
||||
part.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, content_type)
|
||||
|
||||
part.setBody(data)
|
||||
return part
|
||||
@ -311,7 +311,7 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
||||
|
||||
def postForm(self, target: str, header_data: str, body_data: bytes, on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> None:
|
||||
post_part = QHttpPart()
|
||||
post_part.setHeader(QNetworkRequest.ContentDispositionHeader, header_data)
|
||||
post_part.setHeader(QNetworkRequest.KnownHeaders.ContentDispositionHeader, header_data)
|
||||
post_part.setBody(body_data)
|
||||
|
||||
self.postFormWithParts(target, [post_part], on_finished, on_progress)
|
||||
@ -357,10 +357,10 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
||||
def _handleOnFinished(self, reply: QNetworkReply) -> None:
|
||||
# Due to garbage collection, we need to cache certain bits of post operations.
|
||||
# As we don't want to keep them around forever, delete them if we get a reply.
|
||||
if reply.operation() == QNetworkAccessManager.PostOperation:
|
||||
if reply.operation() == QNetworkAccessManager.Operation.PostOperation:
|
||||
self._clearCachedMultiPart(reply)
|
||||
|
||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) is None:
|
||||
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) is None:
|
||||
# No status code means it never even reached remote.
|
||||
return
|
||||
|
||||
|
@ -148,10 +148,10 @@ def exceptHook(hook_type, value, traceback):
|
||||
# The flag "CuraApplication.Created" is set to True when CuraApplication finishes its constructor call.
|
||||
#
|
||||
# Before the "started" flag is set to True, the Qt event loop has not started yet. The event loop is a blocking
|
||||
# call to the QApplication.exec_(). In this case, we need to:
|
||||
# call to the QApplication.exec(). In this case, we need to:
|
||||
# 1. Remove all scheduled events so no more unnecessary events will be processed, such as loading the main dialog,
|
||||
# loading the machine, etc.
|
||||
# 2. Start the Qt event loop with exec_() and show the Crash Dialog.
|
||||
# 2. Start the Qt event loop with exec() and show the Crash Dialog.
|
||||
#
|
||||
# If the application has finished its initialization and was running fine, and then something causes a crash,
|
||||
# we run the old routine to show the Crash Dialog.
|
||||
@ -164,7 +164,7 @@ def exceptHook(hook_type, value, traceback):
|
||||
if not has_started:
|
||||
CuraApplication.getInstance().removePostedEvents(None)
|
||||
_crash_handler.early_crash_dialog.show()
|
||||
sys.exit(CuraApplication.getInstance().exec_())
|
||||
sys.exit(CuraApplication.getInstance().exec())
|
||||
else:
|
||||
_crash_handler.show()
|
||||
else:
|
||||
|
@ -53,7 +53,7 @@ class RestoreBackupJob(Job):
|
||||
def _onRestoreRequestCompleted(self, reply: QNetworkReply, error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
||||
if not HttpRequestManager.replyIndicatesSuccess(reply, error):
|
||||
Logger.warning("Requesting backup failed, response code %s while trying to connect to %s",
|
||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url())
|
||||
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url())
|
||||
self.restore_backup_error_message = self.DEFAULT_ERROR_MESSAGE
|
||||
self._job_done.set()
|
||||
return
|
||||
|
@ -120,9 +120,9 @@ class DFFileUploader:
|
||||
"""
|
||||
|
||||
Logger.log("i", "Finished callback %s %s",
|
||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url().toString())
|
||||
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url().toString())
|
||||
|
||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) # type: Optional[int]
|
||||
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) # type: Optional[int]
|
||||
if not status_code:
|
||||
Logger.log("e", "Reply contained no status code.")
|
||||
self._onUploadError(reply, None)
|
||||
|
@ -228,7 +228,7 @@ class DigitalFactoryApiClient:
|
||||
self._anti_gc_callbacks.remove(parse)
|
||||
|
||||
# Don't try to parse the reply if we didn't get one
|
||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) is None:
|
||||
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) is None:
|
||||
if on_error is not None:
|
||||
on_error()
|
||||
return
|
||||
@ -250,7 +250,7 @@ class DigitalFactoryApiClient:
|
||||
:return: A tuple with a status code and a dictionary.
|
||||
"""
|
||||
|
||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||
try:
|
||||
response = bytes(reply.readAll()).decode()
|
||||
return status_code, json.loads(response)
|
||||
|
@ -289,7 +289,7 @@ class SliceInfo(QObject, Extension):
|
||||
Logger.logException("e", "Exception raised while sending slice info.") # But we should be notified about these problems of course.
|
||||
|
||||
def _onRequestFinished(self, reply: "QNetworkReply") -> None:
|
||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||
if status_code == 200:
|
||||
Logger.log("i", "SliceInfo sent successfully")
|
||||
return
|
||||
|
@ -70,10 +70,10 @@ class CloudPackageChecker(QObject):
|
||||
scope = self._scope)
|
||||
|
||||
def _onUserPackagesRequestFinished(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
||||
if error is not None or reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
|
||||
if error is not None or reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) != 200:
|
||||
Logger.log("w",
|
||||
"Requesting user packages failed, response code %s while trying to connect to %s",
|
||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url())
|
||||
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url())
|
||||
self._application.getCuraAPI().account.setSyncState(self.SYNC_SERVICE_NAME, SyncState.ERROR)
|
||||
return
|
||||
|
||||
|
@ -589,11 +589,11 @@ class Toolbox(QObject, Extension):
|
||||
self.setViewPage("errored")
|
||||
|
||||
def _onDataRequestFinished(self, request_type: str, reply: "QNetworkReply") -> None:
|
||||
if reply.operation() != QNetworkAccessManager.GetOperation:
|
||||
if reply.operation() != QNetworkAccessManager.Operation.GetOperation:
|
||||
Logger.log("e", "_onDataRequestFinished() only handles GET requests but got [%s] instead", reply.operation())
|
||||
return
|
||||
|
||||
http_status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||
http_status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||
if http_status_code != 200:
|
||||
Logger.log("e", "Request type [%s] got non-200 HTTP response: [%s]", http_status_code)
|
||||
self.setViewPage("errored")
|
||||
@ -650,7 +650,7 @@ class Toolbox(QObject, Extension):
|
||||
def _onDownloadFinished(self, reply: "QNetworkReply") -> None:
|
||||
self.resetDownload()
|
||||
|
||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
|
||||
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) != 200:
|
||||
try:
|
||||
reply_error = json.loads(reply.readAll().data().decode("utf-8"))
|
||||
except Exception as e:
|
||||
|
@ -165,7 +165,7 @@ class CloudApiClient:
|
||||
|
||||
request = QNetworkRequest(QUrl(path))
|
||||
if content_type:
|
||||
request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
||||
request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, content_type)
|
||||
access_token = self._account.accessToken
|
||||
if access_token:
|
||||
request.setRawHeader(b"Authorization", "Bearer {}".format(access_token).encode())
|
||||
@ -179,7 +179,7 @@ class CloudApiClient:
|
||||
:return: A tuple with a status code and a dictionary.
|
||||
"""
|
||||
|
||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||
try:
|
||||
response = bytes(reply.readAll()).decode()
|
||||
return status_code, json.loads(response)
|
||||
@ -233,7 +233,7 @@ class CloudApiClient:
|
||||
self._anti_gc_callbacks.remove(parse)
|
||||
|
||||
# Don't try to parse the reply if we didn't get one
|
||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) is None:
|
||||
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) is None:
|
||||
if on_error is not None:
|
||||
on_error()
|
||||
return
|
||||
|
@ -272,7 +272,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||
"""
|
||||
Displays a message when an error occurs specific to uploading print job (i.e. queue is full).
|
||||
"""
|
||||
error_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||
error_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||
if error_code == 409:
|
||||
PrintJobUploadQueueFullMessage().show()
|
||||
else:
|
||||
|
@ -106,9 +106,9 @@ class ToolPathUploader:
|
||||
"""Checks whether a chunk of data was uploaded successfully, starting the next chunk if needed."""
|
||||
|
||||
Logger.log("i", "Finished callback %s %s",
|
||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url().toString())
|
||||
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url().toString())
|
||||
|
||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) # type: Optional[int]
|
||||
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) # type: Optional[int]
|
||||
if not status_code:
|
||||
Logger.log("e", "Reply contained no status code.")
|
||||
self._errorCallback(reply, None)
|
||||
|
@ -42,6 +42,6 @@ class UM3PrintJobOutputModel(PrintJobOutputModel):
|
||||
def _onImageLoaded(self, reply: QNetworkReply, error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
||||
if not HttpRequestManager.replyIndicatesSuccess(reply, error):
|
||||
Logger.warning("Requesting preview image failed, response code {0} while trying to connect to {1}".format(
|
||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url()))
|
||||
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url()))
|
||||
return
|
||||
self.updatePreviewImageData(reply.readAll())
|
||||
|
@ -118,9 +118,9 @@ class ClusterApiClient:
|
||||
"""
|
||||
url = QUrl("http://" + self._address + path)
|
||||
request = QNetworkRequest(url)
|
||||
request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True)
|
||||
request.setAttribute(QNetworkRequest.Attribute.RedirectPolicyAttribute, QNetworkRequest.RedirectPolicy.ManualRedirectPolicy)
|
||||
if content_type:
|
||||
request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
||||
request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, content_type)
|
||||
return request
|
||||
|
||||
@staticmethod
|
||||
@ -130,7 +130,7 @@ class ClusterApiClient:
|
||||
:param reply: The reply from the server.
|
||||
:return: A tuple with a status code and a dictionary.
|
||||
"""
|
||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||
try:
|
||||
response = bytes(reply.readAll()).decode()
|
||||
return status_code, json.loads(response)
|
||||
@ -173,7 +173,7 @@ class ClusterApiClient:
|
||||
self._anti_gc_callbacks.remove(parse)
|
||||
|
||||
# Don't try to parse the reply if we didn't get one
|
||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) is None:
|
||||
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) is None:
|
||||
return
|
||||
|
||||
if reply.error() > 0:
|
||||
|
@ -152,7 +152,7 @@ class SendMaterialJob(Job):
|
||||
def _sendingFinished(self, reply: QNetworkReply) -> None:
|
||||
"""Check a reply from an upload to the printer and log an error when the call failed"""
|
||||
|
||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
|
||||
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) != 200:
|
||||
Logger.log("w", "Error while syncing material: %s", reply.errorString())
|
||||
return
|
||||
body = reply.readAll().data().decode('utf8')
|
||||
|
@ -43,7 +43,7 @@ def test_post():
|
||||
|
||||
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
||||
reply = MagicMock()
|
||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.PostOperation)
|
||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.Operation.PostOperation)
|
||||
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
||||
mocked_network_manager.post = MagicMock(return_value = reply)
|
||||
|
||||
@ -65,7 +65,7 @@ def test_get():
|
||||
|
||||
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
||||
reply = MagicMock()
|
||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.PostOperation)
|
||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.Operation.PostOperation)
|
||||
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
||||
mocked_network_manager.get = MagicMock(return_value=reply)
|
||||
|
||||
@ -87,7 +87,7 @@ def test_delete():
|
||||
|
||||
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
||||
reply = MagicMock()
|
||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.PostOperation)
|
||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.Operation.PostOperation)
|
||||
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
||||
mocked_network_manager.deleteResource = MagicMock(return_value=reply)
|
||||
|
||||
@ -109,7 +109,7 @@ def test_put():
|
||||
|
||||
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
||||
reply = MagicMock()
|
||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.PostOperation)
|
||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.Operation.PostOperation)
|
||||
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
||||
mocked_network_manager.put = MagicMock(return_value = reply)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user