From ffd3277854969b0b06c1cc0f6dc93578443373af Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 11 Oct 2021 14:57:21 +0200 Subject: [PATCH] Show error if the upload failed Contributes to issue CURA-8609. --- cura/Machines/Models/MaterialManagementModel.py | 4 +++- cura/PrinterOutput/UploadMaterialsJob.py | 10 ++++++---- .../Preferences/Materials/MaterialsSyncDialog.qml | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cura/Machines/Models/MaterialManagementModel.py b/cura/Machines/Models/MaterialManagementModel.py index ecd809fef0..f18a5c302c 100644 --- a/cura/Machines/Models/MaterialManagementModel.py +++ b/cura/Machines/Models/MaterialManagementModel.py @@ -405,6 +405,8 @@ class MaterialManagementModel(QObject): job.uploadCompleted.connect(self.exportUploadCompleted) job.start() - def exportUploadCompleted(self): + def exportUploadCompleted(self, job_result: UploadMaterialsJob.Result): + if job_result == UploadMaterialsJob.Result.FAILED: + self._sync_all_dialog.setProperty("syncStatusText", catalog.i18nc("@text", "Something went wrong when sending the materials to the printers.")) self._export_upload_status = "idle" self.exportUploadStatusChanged.emit() \ No newline at end of file diff --git a/cura/PrinterOutput/UploadMaterialsJob.py b/cura/PrinterOutput/UploadMaterialsJob.py index 13e97a5093..45ac653337 100644 --- a/cura/PrinterOutput/UploadMaterialsJob.py +++ b/cura/PrinterOutput/UploadMaterialsJob.py @@ -79,9 +79,11 @@ class UploadMaterialsJob(Job): if error is not None: Logger.error(f"Failed to upload material archive: {error}") self.setResult(self.Result.FAILED) - return - self.setResult(self.Result.SUCCESS) - self.uploadCompleted.emit() + else: + self.setResult(self.Result.SUCCESS) + self.uploadCompleted.emit(self.getResult()) def onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]): - pass # TODO: Handle errors. \ No newline at end of file + Logger.error(f"Failed to upload material archive: {error}") + self.setResult(self.Result.FAILED) + self.uploadCompleted.emit(self.getResult()) \ No newline at end of file diff --git a/resources/qml/Preferences/Materials/MaterialsSyncDialog.qml b/resources/qml/Preferences/Materials/MaterialsSyncDialog.qml index be9f2eb06e..69d30167c2 100644 --- a/resources/qml/Preferences/Materials/MaterialsSyncDialog.qml +++ b/resources/qml/Preferences/Materials/MaterialsSyncDialog.qml @@ -23,6 +23,7 @@ Window property variant materialManagementModel property alias pageIndex: swipeView.currentIndex + property alias syncStatusText: syncStatusLabel.text SwipeView { @@ -358,6 +359,19 @@ Window return materialManagementModel.exportUploadStatus != "uploading"; } } + Label + { + id: syncStatusLabel + + anchors.right: syncButton.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.verticalCenter: parent.verticalCenter + + visible: syncButton.visible + text: "" + color: UM.Theme.getColor("text") + font: UM.Theme.getFont("default") + } Item { anchors.right: parent.right