From 8a87c73a5f633d6cdcb806396ef0fe4259b75427 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 26 Oct 2006 11:39:21 +0000 Subject: [PATCH] Implement method to add global preferences group (from Python modules) --- .../SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx | 10 +++++++ .../SALOME_PYQT_GUI/SALOME_PYQT_Module.h | 1 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 26 +++++++++++++++++++ src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 1 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 1 + src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip | 1 + 6 files changed, 40 insertions(+) diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx index d2e912610..bbe4a419c 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx @@ -25,6 +25,7 @@ #include "STD_TabDesktop.h" #include "SalomeApp_Application.h" #include "SalomeApp_Study.h" +#include "LightApp_Preferences.h" #include "QtxWorkstack.h" #include "QtxActionMenuMgr.h" @@ -1496,6 +1497,15 @@ bool SALOME_PYQT_Module::clearMenu( const int id, const int menu, const bool rem * This is done to open protected methods from LightApp_Module class. */ +int SALOME_PYQT_Module::addGlobalPreference( const QString& label ) +{ + LightApp_Preferences* pref = preferences(); + if ( !pref ) + return -1; + + return pref->addPreference( label, -1 ); +} + int SALOME_PYQT_Module::addPreference( const QString& label ) { return SalomeApp_Module::addPreference( label ); diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h index 51f3a8215..8814e0b66 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h @@ -151,6 +151,7 @@ public: QIconSet loadIcon( const QString& fileName ); /* working with preferences : open protected methods */ + int addGlobalPreference( const QString& ); int addPreference( const QString& ); int addPreference( const QString&, const int, const int = -1, const QString& = QString::null, diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index a67c67484..c88d60771 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -1365,6 +1365,32 @@ bool SalomePyQt::clearMenu( const int id, const int menu, const bool removeActio return ProcessEvent( new TClearMenuEvent( id, menu, removeActions ) ); } +/*! + SalomePyQt::addGlobalPreference + Adds global (not module) preferences group + */ +class TAddGlobalPrefEvent: public SALOME_Event { +public: + typedef int TResult; + TResult myResult; + QString myLabel; + TAddGlobalPrefEvent( const QString& label ) + : myResult( -1 ), myLabel( label ) {} + virtual void Execute() { + if ( SalomeApp_Application* anApp = getApplication() ) { + SALOME_PYQT_Module* module = SALOME_PYQT_Module::getInitModule(); + if ( !module ) + module = dynamic_cast( anApp->activeModule() ); + if ( module ) + myResult = module->addGlobalPreference( myLabel ); + } + } +}; +int SalomePyQt::addGlobalPreference( const QString& label ) +{ + return ProcessEvent( new TAddGlobalPrefEvent( label ) ); +} + /*! SalomePyQt::addPreference Adds preference diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 6a6a0e8af..6f18c9fc0 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -162,6 +162,7 @@ public: static void removeSettings ( const QString& ); static QString getSetting ( const QString& ); + static int addGlobalPreference( const QString& ); static int addPreference( const QString& ); static int addPreference( const QString&, const int, const int = -1, diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index ecd8886b5..c477d6b36 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -149,6 +149,7 @@ public: static void removeSettings ( const QString& ); static QString getSetting ( const QString& ); + static int addGlobalPreference( const QString& ); static int addPreference( const QString& ); static int addPreference( const QString&, const int, int = -1, const QString& = QString::null, diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip index 5bf15f159..7fc90bb12 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip @@ -148,6 +148,7 @@ public: static void removeSettings ( const QString& ) /ReleaseGIL/ ; static QString getSetting ( const QString& ) /ReleaseGIL/ ; + static int addGlobalPreference( const QString& ) /ReleaseGIL/ ; static int addPreference( const QString& ) /ReleaseGIL/ ; static int addPreference( const QString&, const int, const int = -1, -- 2.39.2