]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Preferences.h
Salome HOME
Preferences improvement
[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 <Config_PropManager.h>
11 #include <SUIT_PreferenceMgr.h>
12 #include <QDialog>
13
14 class SUIT_ResourceMgr;
15 class QWidget;
16
17 // Pair of values: section name, value name
18 typedef QPair<QString, QString> XGUI_Pref;
19 typedef QList<XGUI_Pref> XGUI_Prefs;
20
21
22 //***********************************************************************
23 /// Class for manipulation  with preferences in the application
24 class XGUI_EXPORT XGUI_Preferences
25 {
26 public:
27   static const QString VIEWER_SECTION;
28   static const QString MENU_SECTION;
29
30   static bool editPreferences(XGUI_Prefs& theModified);
31
32   static SUIT_ResourceMgr* resourceMgr();
33
34   static void updateCustomProps();
35
36   static void loadCustomProps();
37
38 private:
39   static SUIT_ResourceMgr* myResourceMgr;
40 };
41
42 //***********************************************************************
43 /// Manager of preferences
44 class XGUI_EXPORT XGUI_PreferencesMgr : public SUIT_PreferenceMgr
45 {
46   Q_OBJECT
47 public:
48   XGUI_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
49     :SUIT_PreferenceMgr(theResource, theParent) {}
50
51   virtual ~XGUI_PreferencesMgr() {}
52
53   XGUI_Prefs modified() const { return myModified; }
54
55 protected:
56   virtual void changedResources( const ResourceMap& theMap);
57
58 private:
59   XGUI_Prefs myModified;
60 };
61
62
63 //***********************************************************************
64 /// Dialog box for preferences editing
65 class XGUI_EXPORT XGUI_PreferencesDlg: public QDialog
66 {
67   Q_OBJECT
68 public:
69   XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
70   virtual ~XGUI_PreferencesDlg();
71
72   bool isChanged() const { return myIsChanged; }
73
74   void modified(XGUI_Prefs& theModified) const;
75
76 public slots:
77   virtual void accept();
78
79 private:
80   void createEditors();
81   void createViewerPage(int thePageId);
82   void createMenuPage(int thePageId);
83   void createCustomPage(int thePageId);
84
85   void updateCustomProps();
86   
87   XGUI_PreferencesMgr* myPreferences;
88   bool myIsChanged;
89 };
90
91
92 #endif