SHAPER 9.16.0
ModuleBase_Preferences.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef ModuleBase_Preferences_H
21#define ModuleBase_Preferences_H
22
23#include "ModuleBase.h"
24#include "ModuleBase_IPrefMgr.h"
25
26#include <SUIT_PreferenceMgr.h>
27#include <QDialog>
28
29class SUIT_ResourceMgr;
30class QWidget;
31
33typedef QPair<QString, QString> ModuleBase_Pref;
34
36typedef QList<ModuleBase_Pref> ModuleBase_Prefs;
37
38//***********************************************************************
41class MODULEBASE_EXPORT ModuleBase_Preferences
42{
43 public:
45 static const QString VIEWER_SECTION;
46
48 static const QString MENU_SECTION;
49
51 static const QString GENERAL_SECTION;
52
55 static bool editPreferences(ModuleBase_Prefs& theModified);
56
58 static SUIT_ResourceMgr* resourceMgr();
59
63 static void setResourceMgr(SUIT_ResourceMgr* theMgr) { myResourceMgr = theMgr; }
64
66 static void updateConfigByResources();
67
69 static void loadCustomProps();
70
74 static void createEditContent(ModuleBase_IPrefMgr* thePref, int thePage);
75
77 static void resetResourcePreferences(SUIT_PreferenceMgr* thePref);
78
80 static void resetConfigPropPreferences(SUIT_PreferenceMgr* thePref);
81
83 static void updateSketchTab(ModuleBase_IPrefMgr* thePref, int thePageId);
84
85private:
87 static void updateResourcesByConfig();
88
90 static void resetConfig();
91
94 static void createGeneralTab(ModuleBase_IPrefMgr* thePref, int thePageId);
95
97 static void createCustomPage(ModuleBase_IPrefMgr* thePref, int thePageId);
98
99 static SUIT_ResourceMgr* myResourceMgr;
100};
101
102//***********************************************************************
105class MODULEBASE_EXPORT ModuleBase_PreferencesMgr : public SUIT_PreferenceMgr
106{
107Q_OBJECT
108 public:
112 ModuleBase_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
113 : SUIT_PreferenceMgr(theResource, theParent)
114 {
115 }
116
118 {
119 }
120
122 ModuleBase_Prefs modified() const
123 {
124 return myModified;
125 }
126
127 protected:
129 virtual void changedResources(const ResourceMap& theMap);
130
131 private:
132 ModuleBase_Prefs myModified;
133};
134
135//***********************************************************************
138class MODULEBASE_EXPORT ModuleBase_PreferencesDlg : public QDialog
139{
140Q_OBJECT
141 public:
145 ModuleBase_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
147
149 bool isChanged() const
150 {
151 return myIsChanged;
152 }
153
156 void modified(ModuleBase_Prefs& theModified) const;
157
158 public slots:
160 virtual void accept();
161
162protected:
163 virtual void showEvent(QShowEvent* theEvent);
164
165protected slots:
167 void onDefault();
168
169 private:
171 void createEditors();
172
174 void createViewerPage(int thePageId);
175
177 void createMenuPage(int thePageId);
178
179 ModuleBase_PreferencesMgr* myPreferences;
180 bool myIsChanged;
181};
182
183#endif
An interface class which provides incapsulation of SUIT_PreferenceMgr class instance It is used in or...
Definition: ModuleBase_IPrefMgr.h:35
Dialog box for preferences editing.
Definition: ModuleBase_Preferences.h:139
bool isChanged() const
Returns True if preferences were changed.
Definition: ModuleBase_Preferences.h:149
Manager of preferences.
Definition: ModuleBase_Preferences.h:106
ModuleBase_PreferencesMgr(QtxResourceMgr *theResource, QWidget *theParent)
Constructor.
Definition: ModuleBase_Preferences.h:112
ModuleBase_Prefs modified() const
Returns True if preferences were modified.
Definition: ModuleBase_Preferences.h:122
Class for manipulation with preferences in the application.
Definition: ModuleBase_Preferences.h:42
static void setResourceMgr(SUIT_ResourceMgr *theMgr)
Sets a resource manager It is used in case of necessity to define external resource manager (not SHAP...
Definition: ModuleBase_Preferences.h:63
static const QString MENU_SECTION
Name of preferences of menu section.
Definition: ModuleBase_Preferences.h:48
static const QString GENERAL_SECTION
Name of preferences of general section.
Definition: ModuleBase_Preferences.h:51
static const QString VIEWER_SECTION
Name of preferences of viewer section.
Definition: ModuleBase_Preferences.h:45