PrintJobAwaitingApprovalMessage.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (c) 2022 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from PyQt6.QtCore import QUrl
  4. from PyQt6.QtGui import QDesktopServices
  5. from UM import i18nCatalog
  6. from UM.Message import Message
  7. I18N_CATALOG = i18nCatalog("cura")
  8. class PrintJobPendingApprovalMessage(Message):
  9. """Message shown when waiting for approval on an uploaded print job."""
  10. def __init__(self, cluster_id: str) -> None:
  11. super().__init__(
  12. text = I18N_CATALOG.i18nc("@info:status", "You will receive a confirmation via email when the print job is approved"),
  13. title=I18N_CATALOG.i18nc("@info:title", "The print job was successfully submitted"),
  14. message_type=Message.MessageType.POSITIVE
  15. )
  16. self.addAction("manage_print_jobs", I18N_CATALOG.i18nc("@action", "Manage print jobs"), "", "")
  17. self.addAction("learn_more", I18N_CATALOG.i18nc("@action", "Learn more"), "", "",
  18. button_style = Message.ActionButtonStyle.LINK,
  19. button_align = Message.ActionButtonAlignment.ALIGN_LEFT)
  20. self.actionTriggered.connect(self._onActionTriggered)
  21. self.cluster_id = cluster_id
  22. def _onActionTriggered(self, message: Message, action: str) -> None:
  23. """ Callback function for the "Manage print jobs" button on the pending approval notification. """
  24. match action:
  25. case "manage_print_jobs":
  26. QDesktopServices.openUrl(QUrl(f"https://digitalfactory.ultimaker.com/app/jobs/{self._cluster.cluster_id}?utm_source=cura&utm_medium=software&utm_campaign=message-printjob-sent"))
  27. case "learn_more":
  28. QDesktopServices.openUrl(QUrl("https://support.ultimaker.com/hc/en-us/articles/5329940078620?utm_source=cura&utm_medium=software&utm_campaign=message-printjob-sent"))