1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_Preferences.h
4 // Created: 07 Aug 2014
5 // Author: Vitaly SMETANNIKOV
7 #ifndef ModuleBase_Preferences_H
8 #define ModuleBase_Preferences_H
10 #include "ModuleBase.h"
11 #include "ModuleBase_IPrefMgr.h"
13 #include <SUIT_PreferenceMgr.h>
16 class SUIT_ResourceMgr;
19 // Pair of values: section name, value name
20 typedef QPair<QString, QString> ModuleBase_Pref;
21 typedef QList<ModuleBase_Pref> ModuleBase_Prefs;
23 //***********************************************************************
24 /// Class for manipulation with preferences in the application
25 class MODULEBASE_EXPORT ModuleBase_Preferences
28 static const QString VIEWER_SECTION;
29 static const QString MENU_SECTION;
31 static bool editPreferences(ModuleBase_Prefs& theModified);
33 /// Returns currently installed resource manager
34 static SUIT_ResourceMgr* resourceMgr();
36 /// Sets a resource manager
37 /// It is used in case of necessity to define external resource manager (not NewGeom)
38 static void setResourceMgr(SUIT_ResourceMgr* theMgr) { myResourceMgr = theMgr; }
40 /// Updates Config_PropManager properties by module from SUIT_ResourceMgr
41 static void updateConfigByResources();
43 /// Updates SUIT_ResourceMgr values by Config_PropManager properties
44 /// \param theUpdateOnlyInvalid flag to update only invalid values, if it is false, all are updated
45 static void updateResourcesByConfig();
47 /// Set default values to the Config_PropManager properties
48 static void resetConfig();
50 /// Loads properties defined by module to Config_PropManager
51 static void loadCustomProps();
54 static void createEditContent(ModuleBase_IPrefMgr* thePref, int thePage);
57 /// Creates content of preferences editing widget
58 static void createCustomPage(ModuleBase_IPrefMgr* thePref, int thePageId);
60 static SUIT_ResourceMgr* myResourceMgr;
63 //***********************************************************************
64 /// Manager of preferences
65 class MODULEBASE_EXPORT ModuleBase_PreferencesMgr : public SUIT_PreferenceMgr
69 ModuleBase_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
70 : SUIT_PreferenceMgr(theResource, theParent)
74 virtual ~ModuleBase_PreferencesMgr()
78 ModuleBase_Prefs modified() const
84 virtual void changedResources(const ResourceMap& theMap);
87 ModuleBase_Prefs myModified;
90 //***********************************************************************
91 /// Dialog box for preferences editing
92 class MODULEBASE_EXPORT ModuleBase_PreferencesDlg : public QDialog
96 ModuleBase_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
97 virtual ~ModuleBase_PreferencesDlg();
99 bool isChanged() const
104 void modified(ModuleBase_Prefs& theModified) const;
107 virtual void accept();
113 /// Create editors for aplication properties
114 void createEditors();
116 /// Create a viewer page in dialog box
117 void createViewerPage(int thePageId);
119 /// Create menu properties page in the dialog box
120 void createMenuPage(int thePageId);
122 ModuleBase_PreferencesMgr* myPreferences;