RestartApplicationPresenter.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (c) 2022 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from UM import i18nCatalog
  4. from UM.Message import Message
  5. from cura.CuraApplication import CuraApplication
  6. class RestartApplicationPresenter:
  7. """Presents a dialog telling the user that a restart is required to apply changes
  8. Since we cannot restart Cura, the app is closed instead when the button is clicked
  9. """
  10. def __init__(self, app: CuraApplication) -> None:
  11. self._app = app
  12. self._i18n_catalog = i18nCatalog("cura")
  13. def present(self) -> None:
  14. app_name = self._app.getApplicationDisplayName()
  15. message = Message(self._i18n_catalog.i18nc("@info:generic",
  16. "You need to quit and restart {} before changes have effect.",
  17. app_name))
  18. message.addAction("quit",
  19. name="Quit " + app_name,
  20. icon = "",
  21. description="Close the application",
  22. button_align=Message.ActionButtonAlignment.ALIGN_RIGHT)
  23. message.actionTriggered.connect(self._quitClicked)
  24. message.show()
  25. def _quitClicked(self, *_):
  26. self._app.windowClosed()