Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

QuitAction.cpp 2.44 KB
Newer Older
1
2
/*****************************************************************************
 * $CAMITK_LICENCE_BEGIN$
3
 *
4
 * CamiTK - Computer Assisted Medical Intervention ToolKit
5
 * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6
 *
7
 * Visit http://camitk.imag.fr for more information
8
9
10
11
12
13
14
15
 *
 * This file is part of CamiTK.
 *
 * CamiTK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * CamiTK is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
18
19
20
21
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with CamiTK.  If not, see <http://www.gnu.org/licenses/>.
 *
23
 * $CAMITK_LICENCE_END$
24
 ****************************************************************************/
25
26
27
28
29
30
31
32
33
34
#include "QuitAction.h"

// CamiTK
#include <Application.h>
#include <MainWindow.h>
#include <Component.h>

using namespace camitk;

// --------------- constructor -------------------
35
QuitAction::QuitAction(ActionExtension* extension) : Action(extension) {
36
    // Setting name, description and input component
37
38
    setName("Quit");
    setEmbedded(false);
39
    setDescription(tr("Exit the application, prompting for additional information if needed"));
40
    setComponent("");
41
    setIcon(QPixmap(":/fileQuit"));
42
43

    // Setting classification family and tags
44
    setFamily("Application");
45
46
    addTag(tr("Quit Application"));
    addTag(tr("Exit Application"));
47

48
    // add a shortcut
49
    getQAction()->setShortcut(QKeySequence::Quit);
50
    getQAction()->setShortcutContext(Qt::ApplicationShortcut);
51
52
53
}

// --------------- getWidget --------------
54
QWidget* QuitAction::getWidget() {
55
56
57
58
59
    return NULL;
}

// --------------- apply -------------------
Action::ApplyStatus QuitAction::apply() {
60
61
62
63
64
65
66
67
68
69
70
    // close all components (and therefore ask the user to savet the modified ones)
    ApplyStatus closeAllStatus = Application::getAction("Close All")->apply();
    if (closeAllStatus == SUCCESS) {
        // Quit the app (will call Application::quitting() and therefore unload all action extensions and delete all actions)
        Application::quit();
        return SUCCESS;
    }
    else {
        // or abort the operation
        return ABORTED;
    }
71
72
}