Salome HOME
90150c67f7c74e4d502297d25132b61a10226b95
[modules/shaper.git] / src / XGUI / XGUI_Preferences.h
1 // File:        XGUI_Preferences.h
2 // Created:     07 Aug 2014
3 // Author:      Vitaly SMETANNIKOV
4
5 #ifndef XGUI_Preferences_H
6 #define XGUI_Preferences_H
7
8 #include "XGUI.h"
9
10 #include <SUIT_PreferenceMgr.h>
11 #include <QDialog>
12
13 class SUIT_ResourceMgr;
14 class QWidget;
15
16 // Pair of values: section name, value name
17 typedef QPair<QString, QString> XGUI_Pref;
18 typedef QList<XGUI_Pref> XGUI_Prefs;
19
20
21 //***********************************************************************
22 /// Class for manipulation  with preferences in the application
23 class XGUI_EXPORT XGUI_Preferences
24 {
25 public:
26   static const QString VIEWER_SECTION;
27   static const QString MENU_SECTION;
28
29   static bool editPreferences(XGUI_Prefs& theModified);
30
31   static SUIT_ResourceMgr* resourceMgr();
32
33 private:
34   static SUIT_ResourceMgr* myResourceMgr;
35 };
36
37 //***********************************************************************
38 /// Manager of preferences
39 class XGUI_EXPORT XGUI_PreferencesMgr : public SUIT_PreferenceMgr
40 {
41   Q_OBJECT
42 public:
43   XGUI_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
44     :SUIT_PreferenceMgr(theResource, theParent) {}
45
46   virtual ~XGUI_PreferencesMgr() {}
47
48   XGUI_Prefs modified() const { return myModified; }
49
50 protected:
51   virtual void changedResources( const ResourceMap& theMap);
52
53 private:
54   XGUI_Prefs myModified;
55 };
56
57
58 //***********************************************************************
59 /// Dialog box for preferences editing
60 class XGUI_EXPORT XGUI_PreferencesDlg: public QDialog
61 {
62   Q_OBJECT
63 public:
64   XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
65   virtual ~XGUI_PreferencesDlg();
66
67   bool isChanged() const { return myIsChanged; }
68
69   void modified(XGUI_Prefs& theModified) const;
70
71 public slots:
72   virtual void accept();
73
74 private:
75   void createEditors();
76   void createViewerPage(int thePageId);
77   void createMenuPage(int thePageId);
78   
79   XGUI_PreferencesMgr* myPreferences;
80   bool myIsChanged;
81 };
82
83
84 #endif