]> SALOME platform Git repositories - modules/gui.git/blob - src/LightApp/LightApp_PreferencesDlg.cxx
Salome HOME
d44586445d60031549401f7f5f6d3328c389d343
[modules/gui.git] / src / LightApp / LightApp_PreferencesDlg.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 // File:      LightApp_PreferencesDlg.cxx
20 // Author:    Sergey TELKOV
21
22 #include "LightApp_PreferencesDlg.h"
23
24 #include "LightApp_Preferences.h"
25
26 #include <qvbox.h>
27 #include <qlayout.h>
28
29 /*!
30   Constructor.
31 */
32 LightApp_PreferencesDlg::LightApp_PreferencesDlg( LightApp_Preferences* prefs, QWidget* parent )
33 : QtxDialog( parent, 0, true, false, OK | Close | Apply ),
34 myPrefs( prefs )
35 {
36   setCaption( tr( "CAPTION" ) );
37
38   QVBoxLayout* main = new QVBoxLayout( mainFrame(), 5 );
39
40   QVBox* base = new QVBox( mainFrame() );
41   main->addWidget( base );
42
43   myPrefs->reparent( base, QPoint( 0, 0 ), true );
44
45   setFocusProxy( myPrefs );
46
47   setButtonPosition( Right, Close );
48
49   setDialogFlags( AlignOnce );
50
51   connect( this, SIGNAL( dlgHelp() ),  this, SLOT( onHelp() ) );
52   connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
53 }
54
55 /*!
56   Destructor.
57 */
58 LightApp_PreferencesDlg::~LightApp_PreferencesDlg()
59 {
60   if ( !myPrefs )
61     return;
62
63   myPrefs->reparent( 0, QPoint( 0, 0 ), false );
64   myPrefs = 0;
65 }
66
67 /*!Show dialog.*/
68 void LightApp_PreferencesDlg::show()
69 {
70   myPrefs->retrieve();
71   myPrefs->toBackup();
72
73   QtxDialog::show();
74 }
75
76 /*!Store preferences on accept.*/
77 void LightApp_PreferencesDlg::accept()
78 {
79   QtxDialog::accept();
80
81   myPrefs->store();
82 }
83
84 /*!Reject. Restore preferences from backup.*/
85 void LightApp_PreferencesDlg::reject()
86 {
87   QtxDialog::reject();
88
89   myPrefs->fromBackup();
90 }
91
92 /*!Do nothing.*/
93 void LightApp_PreferencesDlg::onHelp()
94 {
95 }
96
97 /*!Store preferences on apply.*/
98 void LightApp_PreferencesDlg::onApply()
99 {
100   myPrefs->store();
101   myPrefs->toBackup();
102 }