From: vsr Date: Tue, 29 Sep 2020 09:44:39 +0000 (+0300) Subject: Add method to Python API (SalomePyQt) to get currect application name X-Git-Tag: V9_6_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1a535472329a44b103c99f55973619116e19018a;p=modules%2Fgui.git Add method to Python API (SalomePyQt) to get currect application name --- diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 4f9d60ac2..45deaf352 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -436,6 +436,29 @@ void SgPyQtUserDefinedContent::retrieve( QtxResourceMgr*, QtxPreferenceMgr* ) \endcode */ +/*! + \fn QString SalomePyQt::getAppName(); + \brief Get application name + \return application name +*/ + +QString SalomePyQt::getAppName() +{ + LightApp_Application* app = getApplication(); + return app == 0 ? QString() : QString(app->metaObject()->className()).split("_").first(); +} + +/*! + \fn bool SalomePyQt::isLightApp(); + \brief Check if SALOME GUI is running in "light" mode. + \return \c true if this is a "light" application; \c false otherwise +*/ + +bool SalomePyQt::isLightApp() +{ + return SalomePyQt::getAppName() != "SalomeApp"; +} + /*! \fn QWidget* SalomePyQt::getDesktop(); \brief Get the active application's desktop window. diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 1afa37d2b..89f312ab0 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -179,6 +179,9 @@ enum Axis { class SalomePyQt { public: + static QString getAppName(); + static bool isLightApp(); + static QWidget* getDesktop(); static QWidget* getMainFrame(); static QMenuBar* getMainMenuBar(); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index 230d7af1a..f78e4e409 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -277,6 +277,9 @@ class SalomePyQt %End public: + static QString getAppName() /ReleaseGIL/ ; + static bool isLightApp() /ReleaseGIL/ ; + /* KeepReference is necessary on method getDesktop with SIP >= 4.15.5 to avoid garbage collection of the Python objects added to the desktop. This causes a small memory leak (the wrapper around desktop object is never garbage collected) but since this object contains only references this is not