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 /// \typedef ModuleBase_Pref Pair of values: section name, value name
20 typedef QPair<QString, QString> ModuleBase_Pref;
22 /// \typedef ModuleBase_Prefs list of preferences
23 typedef QList<ModuleBase_Pref> ModuleBase_Prefs;
25 //***********************************************************************
26 /// Class for manipulation with preferences in the application
27 class MODULEBASE_EXPORT ModuleBase_Preferences
30 static const QString VIEWER_SECTION;
31 static const QString MENU_SECTION;
33 static bool editPreferences(ModuleBase_Prefs& theModified);
35 /// Returns currently installed resource manager
36 static SUIT_ResourceMgr* resourceMgr();
38 /// Sets a resource manager
39 /// It is used in case of necessity to define external resource manager (not NewGeom)
40 /// \param theMgr resource manager
41 static void setResourceMgr(SUIT_ResourceMgr* theMgr) { myResourceMgr = theMgr; }
43 /// Updates Config_PropManager properties by module from SUIT_ResourceMgr
44 static void updateConfigByResources();
46 /// Updates SUIT_ResourceMgr values by Config_PropManager properties
47 /// \param theUpdateOnlyInvalid flag to update only invalid values, if it is false, all are updated
48 static void updateResourcesByConfig();
50 /// Set default values to the Config_PropManager properties
51 static void resetConfig();
53 /// Loads properties defined by module to Config_PropManager
54 static void loadCustomProps();
56 /// Create editable content
57 /// \param thePref interface to preference manager
58 /// \param thePage an id of a page
59 static void createEditContent(ModuleBase_IPrefMgr* thePref, int thePage);
62 /// Creates content of preferences editing widget
63 static void createCustomPage(ModuleBase_IPrefMgr* thePref, int thePageId);
65 static SUIT_ResourceMgr* myResourceMgr;
68 //***********************************************************************
69 /// Manager of preferences
70 class MODULEBASE_EXPORT ModuleBase_PreferencesMgr : public SUIT_PreferenceMgr
75 /// \param theResource resource manager
76 /// \param theParent a paren widget
77 ModuleBase_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
78 : SUIT_PreferenceMgr(theResource, theParent)
82 virtual ~ModuleBase_PreferencesMgr()
86 ModuleBase_Prefs modified() const
92 virtual void changedResources(const ResourceMap& theMap);
95 ModuleBase_Prefs myModified;
98 //***********************************************************************
99 /// Dialog box for preferences editing
100 class MODULEBASE_EXPORT ModuleBase_PreferencesDlg : public QDialog
104 ModuleBase_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
105 virtual ~ModuleBase_PreferencesDlg();
107 bool isChanged() const
112 void modified(ModuleBase_Prefs& theModified) const;
115 virtual void accept();
121 /// Create editors for aplication properties
122 void createEditors();
124 /// Create a viewer page in dialog box
125 void createViewerPage(int thePageId);
127 /// Create menu properties page in the dialog box
128 void createMenuPage(int thePageId);
130 ModuleBase_PreferencesMgr* myPreferences;