diff options
author | Remco Burema <r.burema@ultimaker.com> | 2021-12-29 13:18:49 +0300 |
---|---|---|
committer | Remco Burema <r.burema@ultimaker.com> | 2021-12-29 13:18:49 +0300 |
commit | 20b435af76505c18d3ff693aef5b845fb7a0b79a (patch) | |
tree | 868cbb62a54cdb4da90c7bc76072af22547b1697 | |
parent | 97da0b9183aa0f499d0738d968e680c82ed75135 (diff) |
Qt5->Qt6: More renamed stuff.
part of CURA-8591
19 files changed, 42 insertions, 42 deletions
diff --git a/cura/CameraAnimation.py b/cura/CameraAnimation.py index 32086c8ba2..699655a31e 100644 --- a/cura/CameraAnimation.py +++ b/cura/CameraAnimation.py @@ -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 diff --git a/cura/CrashHandler.py b/cura/CrashHandler.py index 563755f6d4..f5ce13e04b 100644 --- a/cura/CrashHandler.py +++ b/cura/CrashHandler.py @@ -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) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index fe39c2a992..c2b67b8fbb 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -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: diff --git a/cura/PrintJobPreviewImageProvider.py b/cura/PrintJobPreviewImageProvider.py index 528f42fb4d..90c115a4b4 100644 --- a/cura/PrintJobPreviewImageProvider.py +++ b/cura/PrintJobPreviewImageProvider.py @@ -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. diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index 3325a18d78..dae24767db 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -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 diff --git a/cura_app.py b/cura_app.py index 2374197b59..da8b3bc18d 100755 --- a/cura_app.py +++ b/cura_app.py @@ -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: diff --git a/plugins/CuraDrive/src/RestoreBackupJob.py b/plugins/CuraDrive/src/RestoreBackupJob.py index 6f20693de9..54c94b389e 100644 --- a/plugins/CuraDrive/src/RestoreBackupJob.py +++ b/plugins/CuraDrive/src/RestoreBackupJob.py @@ -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 diff --git a/plugins/DigitalLibrary/src/DFFileUploader.py b/plugins/DigitalLibrary/src/DFFileUploader.py index f206c736cc..6cad7828e2 100644 --- a/plugins/DigitalLibrary/src/DFFileUploader.py +++ b/plugins/DigitalLibrary/src/DFFileUploader.py @@ -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) diff --git a/plugins/DigitalLibrary/src/DigitalFactoryApiClient.py b/plugins/DigitalLibrary/src/DigitalFactoryApiClient.py index 9654bf3373..3456638ba6 100644 --- a/plugins/DigitalLibrary/src/DigitalFactoryApiClient.py +++ b/plugins/DigitalLibrary/src/DigitalFactoryApiClient.py @@ -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) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index bd0bd96baa..0bf76f8423 100755 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -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 diff --git a/plugins/Toolbox/src/CloudSync/CloudPackageChecker.py b/plugins/Toolbox/src/CloudSync/CloudPackageChecker.py index 7a6a04d88c..9f6f48efa4 100644 --- a/plugins/Toolbox/src/CloudSync/CloudPackageChecker.py +++ b/plugins/Toolbox/src/CloudSync/CloudPackageChecker.py @@ -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 diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 4fdd70726a..44b62b64af 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -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: diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py index 971f6786c0..470e57947e 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py @@ -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 diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 50028b9614..8c45ce537f 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -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: diff --git a/plugins/UM3NetworkPrinting/src/Cloud/ToolPathUploader.py b/plugins/UM3NetworkPrinting/src/Cloud/ToolPathUploader.py index 54a0a27332..1881d90923 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/ToolPathUploader.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/ToolPathUploader.py @@ -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) diff --git a/plugins/UM3NetworkPrinting/src/Models/UM3PrintJobOutputModel.py b/plugins/UM3NetworkPrinting/src/Models/UM3PrintJobOutputModel.py index 45d6431acd..85651244f9 100644 --- a/plugins/UM3NetworkPrinting/src/Models/UM3PrintJobOutputModel.py +++ b/plugins/UM3NetworkPrinting/src/Models/UM3PrintJobOutputModel.py @@ -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()) diff --git a/plugins/UM3NetworkPrinting/src/Network/ClusterApiClient.py b/plugins/UM3NetworkPrinting/src/Network/ClusterApiClient.py index a562a59384..b3df000f7b 100644 --- a/plugins/UM3NetworkPrinting/src/Network/ClusterApiClient.py +++ b/plugins/UM3NetworkPrinting/src/Network/ClusterApiClient.py @@ -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: diff --git a/plugins/UM3NetworkPrinting/src/Network/SendMaterialJob.py b/plugins/UM3NetworkPrinting/src/Network/SendMaterialJob.py index dae7942604..32e20892ac 100644 --- a/plugins/UM3NetworkPrinting/src/Network/SendMaterialJob.py +++ b/plugins/UM3NetworkPrinting/src/Network/SendMaterialJob.py @@ -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') diff --git a/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py b/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py index 9d91f83576..984051d589 100644 --- a/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py +++ b/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py @@ -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) |