RestartApplicationPresenter.py 1.2 KB

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