Salome HOME
Fix a bug of SALOME_PYQT package - to work properly with Sip and PyQt libraries addit...
[modules/gui.git] / src / SalomeApp / SalomeApp_PreferencesDlg.cxx
1 // File:      SalomeApp_PreferencesDlg.cxx
2 // Author:    Sergey TELKOV
3
4 #include "SalomeApp_PreferencesDlg.h"
5
6 #include "SalomeApp_Preferences.h"
7
8 #include <qvbox.h>
9 #include <qlayout.h>
10
11 /*!
12   Constructor.
13 */
14 SalomeApp_PreferencesDlg::SalomeApp_PreferencesDlg( SalomeApp_Preferences* prefs, QWidget* parent )
15 : QtxDialog( parent, 0, true, false, OK | Cancel | Apply ),
16 myPrefs( prefs )
17 {
18   setCaption( tr( "CAPTION" ) );
19
20   QVBoxLayout* main = new QVBoxLayout( mainFrame(), 5 );
21
22   QVBox* base = new QVBox( mainFrame() );
23   main->addWidget( base );
24
25   myPrefs->reparent( base, QPoint( 0, 0 ), true );
26
27   setFocusProxy( myPrefs );
28
29   setDialogFlags( AlignOnce );
30
31   connect( this, SIGNAL( dlgHelp() ),  this, SLOT( onHelp() ) );
32   connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
33 }
34
35 /*!
36   Destructor.
37 */
38 SalomeApp_PreferencesDlg::~SalomeApp_PreferencesDlg()
39 {
40   if ( !myPrefs )
41     return;
42
43   myPrefs->reparent( 0, QPoint( 0, 0 ), false );
44   myPrefs = 0;
45 }
46
47 /*!Show dialog.*/
48 void SalomeApp_PreferencesDlg::show()
49 {
50   myPrefs->retrieve();
51   myPrefs->toBackup();
52
53   QtxDialog::show();
54 }
55
56 /*!Store preferences on accept.*/
57 void SalomeApp_PreferencesDlg::accept()
58 {
59   QtxDialog::accept();
60
61   myPrefs->store();
62 }
63
64 /*!Reject. Restore preferences from backup.*/
65 void SalomeApp_PreferencesDlg::reject()
66 {
67   QtxDialog::reject();
68
69   myPrefs->fromBackup();
70 }
71
72 /*!Do nothing.*/
73 void SalomeApp_PreferencesDlg::onHelp()
74 {
75 }
76
77 /*!Store preferences on apply.*/
78 void SalomeApp_PreferencesDlg::onApply()
79 {
80   myPrefs->store();
81 }