]> SALOME platform Git repositories - modules/gui.git/blob - src/STD/STD_CloseDlg.cxx
Salome HOME
4db2d0bd9747d2d18322bbab4d1e8ae26ab944f0
[modules/gui.git] / src / STD / STD_CloseDlg.cxx
1 #include "STD_CloseDlg.h"
2
3 #include <qlabel.h> 
4 #include <qlayout.h> 
5 #include <qpushbutton.h>
6 #include <qmessagebox.h>
7 #include <qhbuttongroup.h>
8
9 #ifndef WNT
10 using namespace std;
11 #endif
12
13 /*!
14  * \brief creates a Close dialog box
15  * \param parent a parent widget
16  * \param modal bool argument, if true the dialog box is a modal dialog box
17  * \param f style flags
18  */
19
20 STD_CloseDlg::STD_CloseDlg( QWidget* parent, bool modal, WFlags f )
21 : QDialog( parent, "", true,  WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
22 {
23   setSizeGripEnabled( true );
24   setCaption( tr( "CLOSE_DLG_CAPTION" ) );
25
26   QVBoxLayout* m_vbL = new QVBoxLayout( this );
27   m_vbL->setMargin( 11 );
28   m_vbL->setSpacing( 6 );
29
30   QLabel* m_lIcon = new QLabel( this, "m_lDescr" );
31   QPixmap pm = QMessageBox::standardIcon( QMessageBox::Warning );
32   m_lIcon->setPixmap( pm );
33   m_lIcon->setScaledContents( false );
34   m_lIcon->setAlignment( Qt::AlignCenter );
35
36   QLabel* m_lDescr = new QLabel (this, "m_lDescr");
37   m_lDescr->setText ( tr ("CLOSE_DLG_DESCRIPTION") );
38   m_lDescr->setAlignment( Qt::AlignCenter );
39   m_lDescr->setMinimumHeight( m_lDescr->sizeHint().height()*5 );
40   m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
41
42   QHBoxLayout* m_hl1 = new QHBoxLayout();
43   m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 );
44   m_hl1->addWidget( m_lIcon );
45   m_hl1->addWidget( m_lDescr );
46
47   m_pb1 = new QPushButton( tr ("CLOSE_DLG_SAVE_CLOSE"), this );
48   m_pb2 = new QPushButton( tr ("CLOSE_DLG_CLOSE"),      this );
49   m_pb3 = new QPushButton( tr ("CLOSE_DLG_UNLOAD"),     this );
50   m_pb4 = new QPushButton( tr ("BUT_CANCEL"), this );
51
52   QGridLayout* m_hl2 = new QGridLayout();
53   m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 );
54   m_hl2->addWidget( m_pb1, 0, 0 );
55   m_hl2->addWidget( m_pb2, 0, 1 );
56   m_hl2->addWidget( m_pb3, 0, 2 );
57   m_hl2->addColSpacing( 3, 10 );
58   m_hl2->setColStretch( 3, 5 );
59   m_hl2->addWidget( m_pb4, 0, 4 );
60   
61   m_vbL->addLayout( m_hl1 );
62   m_vbL->addLayout( m_hl2 );
63
64   connect( m_pb1, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
65   connect( m_pb2, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
66   connect( m_pb3, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
67   connect( m_pb4, SIGNAL( clicked() ), this, SLOT( reject() ) );
68 }
69
70 //================================================================================
71 /*!
72  * \brief reaction on clicked(pressed) button
73  */
74 //================================================================================
75
76 void STD_CloseDlg::onButtonClicked()
77 {
78   QPushButton* btn = ( QPushButton* )sender();
79   if ( btn == m_pb1 )
80     done( 1 );
81   if ( btn == m_pb2 )
82     done( 2 );
83   if ( btn == m_pb3 )
84     done( 3 );
85 }