From 38a197b5e8d857886e1dd4bef461daa456937bf8 Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Thu, 9 Feb 2023 13:12:14 +0100 Subject: [PATCH] bos #29467 SALOME GUI logger --- src/CAM/CAM_Application.cxx | 10 +++++--- src/CAM/resources/CAM_msg_en.ts | 8 +++++++ src/CAM/resources/CAM_msg_fr.ts | 28 +++++++++++++++++++++++ src/CAM/resources/CAM_msg_ja.ts | 28 +++++++++++++++++++++++ src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 20 ++++++++++++++++ src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 1 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 1 + 7 files changed, 93 insertions(+), 3 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 1473f6ff2..2735234a1 100644 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -464,9 +464,9 @@ bool CAM_Application::activateModule( CAM_Module* mod ) if ( myModule ) { - if ( !myModule->deactivateModule( activeStudy() ) ) + if ( myModule->deactivateModule( activeStudy() ) ) { - // ??? + logUserEvent( tr( "MODULE_DEACTIVATED" ).arg( myModule->moduleName() ) ); } moduleDeactivated( myModule ); } @@ -476,7 +476,11 @@ bool CAM_Application::activateModule( CAM_Module* mod ) { // Connect the module to the active study myModule->connectToStudy( dynamic_cast( activeStudy() ) ); - if ( !myModule->activateModule( activeStudy() ) ) + if ( myModule->activateModule( activeStudy() ) ) + { + logUserEvent( tr( "MODULE_ACTIVATED" ).arg( myModule->moduleName() ) ); + } + else { myModule->setMenuShown( false ); myModule->setToolShown( false ); diff --git a/src/CAM/resources/CAM_msg_en.ts b/src/CAM/resources/CAM_msg_en.ts index fb54357e4..ca34b81a5 100644 --- a/src/CAM/resources/CAM_msg_en.ts +++ b/src/CAM/resources/CAM_msg_en.ts @@ -35,5 +35,13 @@ OPERATION_APPLIED operation applied + + MODULE_ACTIVATED + Module %1 activated + + + MODULE_DEACTIVATED + Module %1 deactivated + diff --git a/src/CAM/resources/CAM_msg_fr.ts b/src/CAM/resources/CAM_msg_fr.ts index 09e8fecd3..d097cac43 100644 --- a/src/CAM/resources/CAM_msg_fr.ts +++ b/src/CAM/resources/CAM_msg_fr.ts @@ -15,5 +15,33 @@ MODULE_ROOT_OBJECT_TOOLTIP %1 objet-racine du module + + ACTION_TRIGGERED + l'action est déclenchée + + + ACTION_TOGGLED + l'action est basculée + + + ACTION_ON + on + + + ACTION_OFF + off + + + OPERATION_APPLIED + opération appliquée + + + MODULE_ACTIVATED + Module %1 activé + + + MODULE_DEACTIVATED + Module %1 désactivé + diff --git a/src/CAM/resources/CAM_msg_ja.ts b/src/CAM/resources/CAM_msg_ja.ts index c01382392..5d6a11e25 100644 --- a/src/CAM/resources/CAM_msg_ja.ts +++ b/src/CAM/resources/CAM_msg_ja.ts @@ -15,5 +15,33 @@ MODULE_ROOT_OBJECT_TOOLTIP %1 module root object + + ACTION_TRIGGERED + action is triggered + + + ACTION_TOGGLED + action is toggled + + + ACTION_ON + on + + + ACTION_OFF + off + + + OPERATION_APPLIED + operation applied + + + MODULE_ACTIVATED + Module %1 activated + + + MODULE_DEACTIVATED + Module %1 deactivated + diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 25efe528d..9d990cc11 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -5144,3 +5144,23 @@ void SalomePyQt::logAction( QAction* action, const QString& moduleName ) }; ProcessVoidEvent( new TEvent( action, moduleName ) ); } + +/*! + \brief Enable/disable action logging. +*/ +void SalomePyQt::setActionLoggingEnabled( bool enabled ) +{ + class TEvent: public SALOME_Event + { + bool myEnabled; + public: + TEvent( bool theEnabled ) : myEnabled( theEnabled ) {} + virtual void Execute() + { + LightApp_Module* module = getActiveModule(); + if ( module ) + module->setActionLoggingEnabled( myEnabled ); + } + }; + ProcessVoidEvent( new TEvent( enabled ) ); +} diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 38a3801fe..6aebda770 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -379,6 +379,7 @@ public: static void logUserEvent( const QString& ); static void logAction( QAction*, const QString& = QString() ); + static void setActionLoggingEnabled( bool ); }; #endif // SALOME_PYQT_H diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index 6f6d5fc37..7d314c7f4 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -498,4 +498,5 @@ public: static void logUserEvent( const QString& ) /ReleaseGIL/ ; static void logAction( QAction*, const QString& = QString() ) /ReleaseGIL/ ; + static void setActionLoggingEnabled( bool ) /ReleaseGIL/ ; }; -- 2.30.2