1 // File: XGUI_Preferences.h
2 // Created: 07 Aug 2014
3 // Author: Vitaly SMETANNIKOV
5 #ifndef XGUI_Preferences_H
6 #define XGUI_Preferences_H
9 #include "XGUI_IPrefMgr.h"
11 #include <SUIT_PreferenceMgr.h>
14 class SUIT_ResourceMgr;
17 // Pair of values: section name, value name
18 typedef QPair<QString, QString> XGUI_Pref;
19 typedef QList<XGUI_Pref> XGUI_Prefs;
21 //***********************************************************************
22 /// Class for manipulation with preferences in the application
23 class XGUI_EXPORT XGUI_Preferences
26 static const QString VIEWER_SECTION;
27 static const QString MENU_SECTION;
29 static bool editPreferences(XGUI_Prefs& theModified);
31 /// Returns currently installed resource manager
32 static SUIT_ResourceMgr* resourceMgr();
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; }
38 /// Updates Config_PropManager properties by module from SUIT_ResourceMgr
39 static void updateConfigByResources();
41 /// Updates SUIT_ResourceMgr values by Config_PropManager properties
42 /// \param theUpdateOnlyInvalid flag to update only invalid values, if it is false, all are updated
43 static void updateResourcesByConfig();
45 /// Set default values to the Config_PropManager properties
46 static void resetConfig();
48 /// Loads properties defined by module to Config_PropManager
49 static void loadCustomProps();
52 static void createEditContent(XGUI_IPrefMgr* thePref, int thePage);
55 /// Creates content of preferences editing widget
56 static void createCustomPage(XGUI_IPrefMgr* thePref, int thePageId);
58 static SUIT_ResourceMgr* myResourceMgr;
61 //***********************************************************************
62 /// Manager of preferences
63 class XGUI_EXPORT XGUI_PreferencesMgr : public SUIT_PreferenceMgr
67 XGUI_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
68 : SUIT_PreferenceMgr(theResource, theParent)
72 virtual ~XGUI_PreferencesMgr()
76 XGUI_Prefs modified() const
82 virtual void changedResources(const ResourceMap& theMap);
85 XGUI_Prefs myModified;
88 //***********************************************************************
89 /// Dialog box for preferences editing
90 class XGUI_EXPORT XGUI_PreferencesDlg : public QDialog
94 XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
95 virtual ~XGUI_PreferencesDlg();
97 bool isChanged() const
102 void modified(XGUI_Prefs& theModified) const;
105 virtual void accept();
111 /// Create editors for aplication properties
112 void createEditors();
114 /// Create a viewer page in dialog box
115 void createViewerPage(int thePageId);
117 /// Create menu properties page in the dialog box
118 void createMenuPage(int thePageId);
120 XGUI_PreferencesMgr* myPreferences;