Welcome to mirror list, hosted at ThFree Co, Russian Federation.

RestartApplicationPresenter.py « CloudSync « src « Toolbox « plugins - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8776d1782a202b9b95577e0c0e14d5d0633e9a4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from UM import i18nCatalog
from UM.Message import Message
from cura.CuraApplication import CuraApplication


class RestartApplicationPresenter:
    """Presents a dialog telling the user that a restart is required to apply changes

    Since we cannot restart Cura, the app is closed instead when the button is clicked
    """
    def __init__(self, app: CuraApplication) -> None:
        self._app = app
        self._i18n_catalog = i18nCatalog("cura")

    def present(self) -> None:
        app_name = self._app.getApplicationDisplayName()

        message = Message(self._i18n_catalog.i18nc("@info:generic",
                                                   "You need to quit and restart {} before changes have effect.",
                                                   app_name))

        message.addAction("quit",
                          name="Quit " + app_name,
                          icon = "",
                          description="Close the application",
                          button_align=Message.ActionButtonAlignment.ALIGN_RIGHT)

        message.actionTriggered.connect(self._quitClicked)
        message.show()

    def _quitClicked(self, *_):
        self._app.windowClosed()