FirmwareUpdateCheckerMessage.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (c) 2018 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, 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 are available for your {machine_name}! It is recommended to update the firmware on your printer.").format(
  13. machine_name = machine_name),
  14. title = i18n_catalog.i18nc(
  15. "@info:title The %s gets replaced with the printer name.",
  16. "New %s firmware available") % machine_name)
  17. self._machine_id = machine_id
  18. self._download_url = download_url
  19. self.addAction(self.STR_ACTION_DOWNLOAD,
  20. i18n_catalog.i18nc("@action:button", "How to update"),
  21. "[no_icon]",
  22. "[no_description]",
  23. button_style = Message.ActionButtonStyle.LINK,
  24. button_align = Message.ActionButtonAlignment.ALIGN_LEFT)
  25. def getMachineId(self) -> int:
  26. return self._machine_id
  27. def getDownloadUrl(self) -> str:
  28. return self._download_url