Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / XGUI / XGUI_Preferences.h
index 5453ec5a93b4dfbe8c5e0c9966845c04bf01684d..a6fbc8a2b2faa2675bb944ff7506e5b531b43745 100644 (file)
 #define XGUI_Preferences_H
 
 #include "XGUI.h"
+#include "XGUI_IPrefMgr.h"
+
+#include <SUIT_PreferenceMgr.h>
 #include <QDialog>
 
 class SUIT_ResourceMgr;
-class SUIT_PreferenceMgr;
 class QWidget;
 
+// Pair of values: section name, value name
+typedef QPair<QString, QString> XGUI_Pref;
+typedef QList<XGUI_Pref> XGUI_Prefs;
+
+//***********************************************************************
+/// Class for manipulation  with preferences in the application
 class XGUI_EXPORT XGUI_Preferences
 {
-public:
+ public:
+  static const QString VIEWER_SECTION;
+  static const QString MENU_SECTION;
 
-  static void editPreferences();
+  static bool editPreferences(XGUI_Prefs& theModified);
 
+  /// Returns currently installed resource manager
   static SUIT_ResourceMgr* resourceMgr();
 
+  /// Sets a resource manager
+  /// It is used in case of necessity to define external resource manager (not NewGeom)
+  static void setResourceMgr(SUIT_ResourceMgr* theMgr) { myResourceMgr = theMgr; }
+
+  /// Updates properties defined by module from SUIT_ResourceMgr to Config_PropManager
+  static void updateCustomProps();
+
+  /// Loads properties defined by module to Config_PropManager
+  static void loadCustomProps();
+
+  /// 
+  static void createEditContent(XGUI_IPrefMgr* thePref, int thePage);
+
 private:
+  /// Creates content of preferences editing widget
+  static void createCustomPage(XGUI_IPrefMgr* thePref, int thePageId);
+
   static SUIT_ResourceMgr* myResourceMgr;
 };
 
+//***********************************************************************
+/// Manager of preferences
+class XGUI_EXPORT XGUI_PreferencesMgr : public SUIT_PreferenceMgr
+{
+Q_OBJECT
+ public:
+  XGUI_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
+      : SUIT_PreferenceMgr(theResource, theParent)
+  {
+  }
+
+  virtual ~XGUI_PreferencesMgr()
+  {
+  }
+
+  XGUI_Prefs modified() const
+  {
+    return myModified;
+  }
 
-class XGUI_PreferencesDlg: public QDialog
+ protected:
+  virtual void changedResources(const ResourceMap& theMap);
+
+ private:
+  XGUI_Prefs myModified;
+};
+
+//***********************************************************************
+/// Dialog box for preferences editing
+class XGUI_EXPORT XGUI_PreferencesDlg : public QDialog
 {
-  Q_OBJECT
-public:
+Q_OBJECT
+ public:
   XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
   virtual ~XGUI_PreferencesDlg();
 
-private:
-  void createEditors();
+  bool isChanged() const
+  {
+    return myIsChanged;
+  }
 
-  SUIT_PreferenceMgr* myPreferences;
-};
+  void modified(XGUI_Prefs& theModified) const;
 
+ public slots:
+  virtual void accept();
+
+ private:
+   /// Create editors for aplication properties
+   void createEditors();
+
+   /// Create a viewer page in dialog box
+   void createViewerPage(int thePageId);
+   
+   /// Create menu properties page in the dialog box
+   void createMenuPage(int thePageId);
+
+  XGUI_PreferencesMgr* myPreferences;
+  bool myIsChanged;
+};
 
-#endif
\ No newline at end of file
+#endif