diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py index 470e57947e..20a7dcc17c 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py @@ -16,6 +16,7 @@ from cura.CuraApplication import CuraApplication from cura.UltimakerCloud import UltimakerCloudConstants from cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope from .ToolPathUploader import ToolPathUploader +from ..Messages.PrintJobAwaitingApprovalMessage import PrintJobPendingApprovalMessage from ..Models.BaseModel import BaseModel from ..Models.Http.CloudClusterResponse import CloudClusterResponse from ..Models.Http.CloudClusterStatus import CloudClusterStatus @@ -241,6 +242,8 @@ class CloudApiClient: status_code, response = self._parseReply(reply) if status_code >= 300 and on_error is not None: on_error() + elif "data" in response and "status" in response["data"] and response["data"]["status"] == "wait_approval": + PrintJobPendingApprovalMessage().show() else: self._parseModels(response, on_finished, model) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index c8a6b30d90..e3eac7da02 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -3,7 +3,7 @@ from time import time import os -from typing import cast, List, Optional, TYPE_CHECKING +from typing import cast, List, Optional from PyQt6.QtCore import QObject, QUrl, pyqtProperty, pyqtSignal, pyqtSlot from PyQt6.QtGui import QDesktopServices @@ -21,7 +21,6 @@ from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from .CloudApiClient import CloudApiClient from ..ExportFileJob import ExportFileJob -from ..Messages.PrintJobAwaitingApprovalMessage import PrintJobPendingApprovalMessage from ..UltimakerNetworkedPrinterOutputDevice import UltimakerNetworkedPrinterOutputDevice from ..Messages.PrintJobUploadBlockedMessage import PrintJobUploadBlockedMessage from ..Messages.PrintJobUploadErrorMessage import PrintJobUploadErrorMessage @@ -232,9 +231,6 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): :param job_response: The response received from the cloud API. """ - if job_response.status is "wait_approval": - PrintJobPendingApprovalMessage().show() - if not self._tool_path: return self._onUploadError() self._pre_upload_print_job = job_response # store the last uploaded job to prevent re-upload of the same file diff --git a/plugins/UM3NetworkPrinting/src/Messages/PrintJobAwaitingApprovalMessage.py b/plugins/UM3NetworkPrinting/src/Messages/PrintJobAwaitingApprovalMessage.py index cacfcd362b..c326a35363 100644 --- a/plugins/UM3NetworkPrinting/src/Messages/PrintJobAwaitingApprovalMessage.py +++ b/plugins/UM3NetworkPrinting/src/Messages/PrintJobAwaitingApprovalMessage.py @@ -1,5 +1,8 @@ # Copyright (c) 2022 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from PyQt6.QtCore import QUrl +from PyQt6.QtGui import QDesktopServices + from UM import i18nCatalog from UM.Message import Message @@ -12,14 +15,19 @@ class PrintJobPendingApprovalMessage(Message): def __init__(self) -> None: super().__init__( - text = I18N_CATALOG.i18nc("@info:status", "The print job was succesfully submitted"), - title=I18N_CATALOG.i18nc("@info:title", "You will recieve a confirmation via email when the print job is approved"), + text = I18N_CATALOG.i18nc("@info:status", "You will receive a confirmation via email when the print job is approved"), + title=I18N_CATALOG.i18nc("@info:title", "The print job was successfully submitted"), message_type=Message.MessageType.POSITIVE ) - self.self.addAction("learn_more", - I18N_CATALOG.i18nc("@action", "Learn more"), - "", - "", - "", - button_style = Message.ActionButtonStyle.LINK, - button_align = Message.ActionButtonAlignment.ALIGN_LEFT) + self.addAction("manage_print_jobs", I18N_CATALOG.i18nc("@action", "Manage print jobs"), "", "") + + self.addAction("learn_more", I18N_CATALOG.i18nc("@action", "Learn more"), "", "", + button_style = Message.ActionButtonStyle.LINK, + button_align = Message.ActionButtonAlignment.ALIGN_LEFT) + + self.actionTriggered.connect(self._onActionTriggered) + + def _onActionTriggered(self, message: Message, action: str): + """ Callback function for the "Manage print jobs" button on the pending approval notification. """ + if action == "manage_print_jobs": + QDesktopServices.openUrl(QUrl("https://ultimaker.com/"))