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