Salome HOME
faf49c9628343218ba7350507b6de663c64f336d
[modules/gui.git] / src / SVTK / SVTK_DialogBase.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 //  SALOME VTKViewer : build VTK viewer into Salome desktop
23 //  File   : 
24 //  Author : 
25 //  Module : SALOME
26 //  $Header$
27 //
28 #include "SVTK_DialogBase.h"
29
30 #include "QtxAction.h"
31
32 /*!
33   Constructor
34 */
35 SVTK_DialogBase
36 ::SVTK_DialogBase(QtxAction* theAction,
37                   QWidget* theParent,
38                   const char* theName, 
39                   bool theModal, 
40                   Qt::WindowFlags theWFalgs):
41   QDialog(theParent, 
42           theWFalgs | Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
43   myAction(theAction)
44 {
45   setObjectName(theName);
46   setModal(theModal);
47
48   connect(theParent, SIGNAL(Show( QShowEvent * )), this, SLOT(onParentShow()));
49   connect(theParent, SIGNAL(Hide( QHideEvent * )), this, SLOT(onParentHide()));
50 }
51
52 /*
53  *  Destroys the object and frees any allocated resources
54  */
55 SVTK_DialogBase
56 ::~SVTK_DialogBase()
57 {
58   // no need to delete child widgets, Qt does it all for us
59 }
60
61 void 
62 SVTK_DialogBase
63 ::onParentShow()
64 {
65   if(myAction->isChecked())
66     show();
67   else
68     hide();
69 }
70
71 void 
72 SVTK_DialogBase
73 ::onParentHide()
74 {
75   hide();
76 }
77
78 void 
79 SVTK_DialogBase
80 ::done( int r )
81 {
82   myAction->setChecked( false );
83   QDialog::done( r );
84 }