]> SALOME platform Git repositories - modules/gui.git/blob - src/STD/STD_CloseDlg.cxx
Salome HOME
ptv, do not send mouse release event just after mouse double click
[modules/gui.git] / src / STD / STD_CloseDlg.cxx
1 #include "STD_CloseDlg.h"
2
3 #include <qpushbutton.h>
4 #include <qhbuttongroup.h>
5 #include <qlayout.h> 
6 #include <qlabel.h> 
7 #include <qmessagebox.h>
8
9 using namespace std;
10
11 //================================================================================
12 /*!
13  * \brief creates a Close dialog box
14  * \param parent a parent widget
15  * \param modal bool argument, if true the dialog box is a modal dialog box
16  * \param f style flags
17  * 
18  */
19 //================================================================================
20
21 STD_CloseDlg::STD_CloseDlg ( QWidget * parent, bool modal, WFlags f )
22      : QDialog ( parent, "", TRUE,  WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
23 {
24   setSizeGripEnabled ( TRUE ) ;
25   setCaption( tr( "CLOSE_DLG_CAPTION" ) );
26
27   QVBoxLayout* m_vbL = new QVBoxLayout( this );
28   m_vbL->setMargin( 11 ); 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 }