Salome HOME
Hide selected object on using it in extrusion
[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 #include "XGUI_IPrefMgr.h"
10
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   /// Returns currently installed resource manager
32   static SUIT_ResourceMgr* resourceMgr();
33
34   /// Sets a resource manager
35   /// It is used in case of necessity to define external resource manager (not NewGeom)
36   static void setResourceMgr(SUIT_ResourceMgr* theMgr) { myResourceMgr = theMgr; }
37
38   /// Updates properties defined by module from SUIT_ResourceMgr to Config_PropManager
39   static void updateCustomProps();
40
41   /// Loads properties defined by module to Config_PropManager
42   static void loadCustomProps();
43
44   /// 
45   static void createEditContent(XGUI_IPrefMgr* thePref, int thePage);
46
47 private:
48   /// Creates content of preferences editing widget
49   static void createCustomPage(XGUI_IPrefMgr* thePref, int thePageId);
50
51   static SUIT_ResourceMgr* myResourceMgr;
52 };
53
54 //***********************************************************************
55 /// Manager of preferences
56 class XGUI_EXPORT XGUI_PreferencesMgr : public SUIT_PreferenceMgr
57 {
58 Q_OBJECT
59  public:
60   XGUI_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
61       : SUIT_PreferenceMgr(theResource, theParent)
62   {
63   }
64
65   virtual ~XGUI_PreferencesMgr()
66   {
67   }
68
69   XGUI_Prefs modified() const
70   {
71     return myModified;
72   }
73
74  protected:
75   virtual void changedResources(const ResourceMap& theMap);
76
77  private:
78   XGUI_Prefs myModified;
79 };
80
81 //***********************************************************************
82 /// Dialog box for preferences editing
83 class XGUI_EXPORT XGUI_PreferencesDlg : public QDialog
84 {
85 Q_OBJECT
86  public:
87   XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
88   virtual ~XGUI_PreferencesDlg();
89
90   bool isChanged() const
91   {
92     return myIsChanged;
93   }
94
95   void modified(XGUI_Prefs& theModified) const;
96
97  public slots:
98   virtual void accept();
99
100  private:
101    /// Create editors for aplication properties
102    void createEditors();
103
104    /// Create a viewer page in dialog box
105    void createViewerPage(int thePageId);
106    
107    /// Create menu properties page in the dialog box
108    void createMenuPage(int thePageId);
109
110   XGUI_PreferencesMgr* myPreferences;
111   bool myIsChanged;
112 };
113
114 #endif