Salome HOME
Add method to Python API (SalomePyQt) to get currect application name
authorvsr <vsr@opencascade.com>
Tue, 29 Sep 2020 09:44:39 +0000 (12:44 +0300)
committervsr <vsr@opencascade.com>
Tue, 29 Sep 2020 09:47:10 +0000 (12:47 +0300)
src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx
src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip

index 4f9d60ac20246a080ec43a2da98b188a03e2379b..45deaf3529588560967e318e32116d07c0f47e5f 100644 (file)
@@ -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.
index 1afa37d2b07c4bacbd14416fad693f571f56400c..89f312ab0c357ab82118112ff48ab438eed0e886 100644 (file)
@@ -179,6 +179,9 @@ enum Axis {
 class SalomePyQt
 {
 public:
+  static QString           getAppName();
+  static bool              isLightApp();
+
   static QWidget*          getDesktop();
   static QWidget*          getMainFrame();
   static QMenuBar*         getMainMenuBar();
index 230d7af1a30e447e97f831f2d86ef956a0f2e462..f78e4e40987e3d239e0eb899e139f403d9084261 100644 (file)
@@ -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