Salome HOME
Sources formated according to the codeing standards
[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 /// 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   static void updateCustomProps();
34
35   static void loadCustomProps();
36
37  private:
38   static SUIT_ResourceMgr* myResourceMgr;
39 };
40
41 //***********************************************************************
42 /// Manager of preferences
43 class XGUI_EXPORT XGUI_PreferencesMgr : public SUIT_PreferenceMgr
44 {
45 Q_OBJECT
46  public:
47   XGUI_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
48       : SUIT_PreferenceMgr(theResource, theParent)
49   {
50   }
51
52   virtual ~XGUI_PreferencesMgr()
53   {
54   }
55
56   XGUI_Prefs modified() const
57   {
58     return myModified;
59   }
60
61  protected:
62   virtual void changedResources(const ResourceMap& theMap);
63
64  private:
65   XGUI_Prefs myModified;
66 };
67
68 //***********************************************************************
69 /// Dialog box for preferences editing
70 class XGUI_EXPORT XGUI_PreferencesDlg : public QDialog
71 {
72 Q_OBJECT
73  public:
74   XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
75   virtual ~XGUI_PreferencesDlg();
76
77   bool isChanged() const
78   {
79     return myIsChanged;
80   }
81
82   void modified(XGUI_Prefs& theModified) const;
83
84  public slots:
85   virtual void accept();
86
87  private:
88   void createEditors();
89   void createViewerPage(int thePageId);
90   void createMenuPage(int thePageId);
91   void createCustomPage(int thePageId);
92
93   void updateCustomProps();
94
95   XGUI_PreferencesMgr* myPreferences;
96   bool myIsChanged;
97 };
98
99 #endif