fw4spl
t/src/fwGuiQt/Application.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include <QApplication>
8 
9 #include <fwGui/dialog/IMessageDialog.hpp>
10 #include <fwGui/dialog/MessageDialog.hpp>
11 #include <fwGui/registry/macros.hpp>
12 
13 #include "fwGuiQt/Application.hpp"
14 
15 
16 fwGuiRegisterMacro(::fwGuiQt::Application, ::fwGui::IApplication::REGISTRY_KEY );
17 
18 namespace fwGuiQt
19 {
20 
21 //-----------------------------------------------------------------------------
22 
23 void Application::exit(int returncode)
24 {
25  if(m_confirm)
26  {
28  dlg.setTitle("Confirm exit");
29  dlg.setMessage("Do you really want to exit?");
30  dlg.setIcon(::fwGui::dialog::IMessageDialog::QUESTION);
31  dlg.addButton(::fwGui::dialog::IMessageDialog::YES_NO);
32 
34 
35  if(res == ::fwGui::dialog::IMessageDialog::YES)
36  {
37  qApp->exit(returncode);
38  }
39  }
40  else
41  {
42  qApp->exit(returncode);
43  }
44 }
45 
46 //-----------------------------------------------------------------------------
47 
48 } // namespace fwGuiQt
49 
50 
51 
Gives access to the qt application part.
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
Defines the generic message box for IHM. Use the Delegate design pattern.
The namespace fwGuiQt contains classes which provide the implementation of the Gui using Qt library...
Definition: WindowLevel.hpp:32
virtual FWGUI_API void addButton(IMessageDialog::Buttons button) override
Add a button (OK, YES_NO, YES, NO, CANCEL)
virtual FWGUI_API IMessageDialog::Buttons show() override
Show the message box and return the clicked button.
virtual FWGUI_API void setIcon(IMessageDialog::Icons icon) override
Set the icon (CRITICAL, WARNING, INFO or QUESTION)
bool m_confirm
Asks confirmation before exiting application.
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the message box.
virtual FWGUIQT_API void exit(int returncode=0)
Tells the application to exit with a returncode.