Salome HOME
Merge branch 'po/29467_gui_log_file'
authorPascal Obry <pascal.obry@edf.fr>
Mon, 11 Sep 2023 07:01:58 +0000 (09:01 +0200)
committerPascal Obry <pascal.obry@edf.fr>
Mon, 11 Sep 2023 07:01:58 +0000 (09:01 +0200)
* po/29467_gui_log_file:
  Use logStructuredUserEvent() for log message format consistency.
  Minor correction
  Log desktop actions
  [bos #29467] [EDF] (2022-T1) Logging of SALOME usage: specific log in SALOME

src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI.h

index 475b4933d71e1b9e4831a01199ad435ef3ce7780..eebf6e6c422ece0e69c5544973008316ad1b99ba 100644 (file)
@@ -100,7 +100,7 @@ static const QString ToolbarsSection("SHAPER_Toolbars");
 static const QString FreeCommandsParam("OutOFToolbars");
 
 
-/** 
+/**
 * Class for preferences management
 */
 class SHAPERGUI_PrefMgr: public ModuleBase_IPrefMgr
@@ -383,6 +383,16 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
   connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
           this, SLOT(onSaveAsDocByShaper()));
   updateInfoPanel();
+
+  //connect(myWorkshop->operationMgr(), SIGNAL(operationResumed(ModuleBase_Operation*)),
+  //        this, SLOT(onOperationResumed(ModuleBase_Operation*)));
+  //connect(myWorkshop->operationMgr(), SIGNAL(operationStopped(ModuleBase_Operation*)),
+  //        this, SLOT(onOperationStopped(ModuleBase_Operation*)));
+  connect(myWorkshop->operationMgr(), SIGNAL(operationCommitted(ModuleBase_Operation*)),
+          this, SLOT(onOperationCommitted(ModuleBase_Operation*)));
+  connect(myWorkshop->operationMgr(), SIGNAL(operationAborted(ModuleBase_Operation*)),
+          this, SLOT(onOperationAborted(ModuleBase_Operation*)));
+
   return isDone;
 }
 
@@ -484,6 +494,53 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
   return LightApp_Module::deactivateModule(theStudy);
 }
 
+//******************************************************
+void SHAPERGUI::logShaperGUIEvent()
+{
+  QAction* anAction = static_cast<QAction*>(sender());
+  if ( !anAction )
+    return;
+  const QString anId = anAction->data().toString();
+  const QString section = anId.contains("Sketch") ? "sketcher" : "";
+
+  CAM_Application::logStructuredUserEvent( moduleName(),
+                                           section,
+                                           anAction->text(),
+                                           "activated" );
+}
+
+//******************************************************
+static void onOperationGeneric( ModuleBase_Operation* theOperation,
+                                const QString moduleName,
+                                const QString &event )
+{
+  QString anId = theOperation->id();
+  QString section = "";
+
+  if (anId.contains("Sketch"))
+  {
+    section = "sketcher";
+    anId.remove("Sketch");
+  }
+
+  CAM_Application::logStructuredUserEvent( moduleName,
+                                           section,
+                                           anId,
+                                           event );
+}
+
+//******************************************************
+void SHAPERGUI::onOperationCommitted(ModuleBase_Operation* theOperation)
+{
+  onOperationGeneric(theOperation, moduleName(), "committed");
+}
+
+//******************************************************
+void SHAPERGUI::onOperationAborted(ModuleBase_Operation* theOperation)
+{
+  onOperationGeneric(theOperation, moduleName(), "aborted");
+}
+
 //******************************************************
 void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr)
 {
@@ -704,6 +761,7 @@ QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theTBNam
     createTool(separator(), aWBTool);
     registerCommandToolbar(theTBName, -1);
   }
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(logShaperGUIEvent()));
   return aAction;
 }
 
@@ -743,6 +801,8 @@ QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
   createTool(separator(), aWBTool); /// nested action is always separated of others
   registerCommandToolbar(theWBName, -1);
 
+  connect(anAction, SIGNAL(triggered(bool)), this, SLOT(logShaperGUIEvent()));
+
   return anAction;
 }
 
@@ -771,6 +831,9 @@ QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTi
   aAction->setStatusTip(theTip);
   aAction->setData(theId);
   createMenu(aId, aMenu, theMenuPosition);
+
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(logShaperGUIEvent()));
+
   return aAction;
 }
 
index aba74c8598ea7d88ce44468c8a340fcbb3282122..2a84accc3bc5bf7ddbd571e1a0f086b656a24f1e 100644 (file)
@@ -36,8 +36,9 @@ class SHAPERGUI_OCCSelector;
 class OCCViewer_Viewer;
 class CAM_Study;
 class QtxInfoPanel;
+class ModuleBase_Operation;
 
-/** 
+/**
  * \ingroup Salome
  * An implementation of SALOME connector class for implementation of
  * XGUI functionality as a module of SALOME
@@ -214,6 +215,9 @@ Q_OBJECT
   /// Obtains the current application and updates its actions
   void onUpdateCommandStatus();
 
+   /// \brief The method is called on any GUI action
+  virtual void logShaperGUIEvent();
+
  protected:
    /// Create data model
   CAM_DataModel* createDataModel();
@@ -229,6 +233,9 @@ private slots:
 
   void onEditToolbars();
 
+  void onOperationCommitted(ModuleBase_Operation*);
+  void onOperationAborted(ModuleBase_Operation*);
+
  private:
    /// Create selector for OCC Viewer
    /// \param theMgr view manager