Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / SalomeApp / SalomeApp_ExitDlg.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File:      SalomeApp_ExitDlg.cxx
23 // Author:    Margarita KARPUNINA, Open CASCADE S.A.S.
24 //
25 #include "SalomeApp_ExitDlg.h"
26
27 #include <QLabel> 
28 #include <QVBoxLayout> 
29 #include <QHBoxLayout> 
30 #include <QGridLayout> 
31 #include <QPushButton>
32 #include <QMessageBox>
33 #include <QCheckBox>
34
35 /*!
36  * \brief creates a Exit dialog box
37  * \param parent a parent widget
38  * \param modal bool argument, if true the dialog box is a modal dialog box
39  * \param f style flags
40  */
41 SalomeApp_ExitDlg::SalomeApp_ExitDlg( QWidget* parent )
42   : QDialog( parent )
43 {
44   setModal( true );
45   setWindowTitle( tr( "INF_DESK_EXIT" ) );
46
47   QVBoxLayout* m_vbL = new QVBoxLayout( this );
48   m_vbL->setMargin( 11 );
49   m_vbL->setSpacing( 6 );
50
51   QLabel* m_lIcon = new QLabel( this );
52   QPixmap pm = QMessageBox::standardIcon( QMessageBox::Question );
53   m_lIcon->setPixmap( pm );
54   m_lIcon->setScaledContents( false );
55   m_lIcon->setAlignment( Qt::AlignCenter );
56
57   QLabel* m_lDescr = new QLabel( this );
58   m_lDescr->setText( tr( "QUE_DESK_EXIT" ) );
59   m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
60
61   myServersShutdown = new QCheckBox( tr( "SHUTDOWN_SERVERS" ), this );
62   myServersShutdown->setChecked( true );
63   
64   QVBoxLayout* m_vl1 = new QVBoxLayout();
65   m_vl1->setMargin( 10 ); m_vl1->setSpacing( 16 );
66   m_vl1->addWidget( m_lDescr );
67   m_vl1->addWidget( myServersShutdown );
68
69   QHBoxLayout* m_hl1 = new QHBoxLayout();
70   m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 );
71   m_hl1->addWidget( m_lIcon );
72   m_hl1->addStretch(); 
73   m_hl1->addLayout( m_vl1 );
74   m_hl1->addStretch();
75
76   QPushButton* m_pbOk     = new QPushButton( tr( "BUT_OK" ),     this );
77   QPushButton* m_pbCancel = new QPushButton( tr( "BUT_CANCEL" ), this );
78
79   QGridLayout* m_hl2 = new QGridLayout();
80   m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 );
81   m_hl2->addWidget( m_pbOk, 0, 0 );
82   m_hl2->setColumnStretch( 1, 5 );
83   m_hl2->addWidget( m_pbCancel, 0, 2 );
84   
85   m_vbL->addStretch();
86   m_vbL->addLayout( m_hl1 );
87   m_vbL->addStretch();
88   m_vbL->addLayout( m_hl2 );
89
90   connect( m_pbOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
91   connect( m_pbCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
92 }
93
94 /*!
95  * \brief Destructor
96  */
97 SalomeApp_ExitDlg::~SalomeApp_ExitDlg()
98 {
99 }
100
101 /*!
102  * \brief get the check box status
103  */
104 bool SalomeApp_ExitDlg::isServersShutdown()
105 {
106   return myServersShutdown->isChecked();
107 }
108