FirmwareUpdateCheckerMessage.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (c) 2020 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from UM.i18n import i18nCatalog
  4. from UM.Message import Message
  5. i18n_catalog = i18nCatalog("cura")
  6. # Make a separate class, since we need an extra field: The machine-id that this message is about.
  7. class FirmwareUpdateCheckerMessage(Message):
  8. STR_ACTION_DOWNLOAD = "download"
  9. def __init__(self, machine_id: int, machine_name: str, latest_version: str, download_url: str) -> None:
  10. super().__init__(i18n_catalog.i18nc(
  11. "@info Don't translate {machine_name}, since it gets replaced by a printer name!",
  12. "New features or bug-fixes may be available for your {machine_name}! If not already at the latest version, "
  13. "it is recommended to update the firmware on your printer to version {latest_version}.").format(
  14. machine_name = machine_name, latest_version = latest_version),
  15. title = i18n_catalog.i18nc(
  16. "@info:title The %s gets replaced with the printer name.",
  17. "New %s firmware available") % machine_name)
  18. self._machine_id = machine_id
  19. self._download_url = download_url
  20. self.addAction(self.STR_ACTION_DOWNLOAD,
  21. i18n_catalog.i18nc("@action:button", "How to update"),
  22. "[no_icon]",
  23. "[no_description]",
  24. button_style = Message.ActionButtonStyle.LINK,
  25. button_align = Message.ActionButtonAlignment.ALIGN_LEFT)
  26. def getMachineId(self) -> int:
  27. return self._machine_id
  28. def getDownloadUrl(self) -> str:
  29. return self._download_url