Salome HOME
Clear info panel when module is deactivated
[modules/gui.git] / src / Qtx / QtxActionMgr.cxx
index 8988a81ed9954297301e3d6bd562fbfac1a2ec18..caef017c84f1c5185d61a392b84c21175a6b1917 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -156,6 +156,8 @@ int QtxActionMgr::registerAction( QAction* a, const int userId )
 
   myActions.insert( theId, a );
 
+  connect( a, SIGNAL( changed() ), this, SLOT( onActionChanged() ) );
+
   return theId;
 }
 
@@ -166,8 +168,11 @@ int QtxActionMgr::registerAction( QAction* a, const int userId )
 */
 void QtxActionMgr::unRegisterAction( const int id )
 {
-  if( contains( id ) )
+  if ( contains( id ) ) {
+    disconnect( myActions[id], SIGNAL( changed() ),
+               this, SLOT( onActionChanged() ) );
     myActions.remove( id );
+  }
 }
 
 /*!
@@ -419,6 +424,13 @@ void QtxActionMgr::updateContent()
 {
 }
 
+/*!
+  \brief Internal action changing response operation.
+*/
+void QtxActionMgr::actionChanged( int )
+{
+}
+
 /*!
   \brief Called when delayed update is performed (via timer event).
 
@@ -430,6 +442,21 @@ void QtxActionMgr::onUpdateContent()
   updateContent();
 }
 
+/*!
+  \brief Called when one of the registered actions changed.
+
+  Calls virtual method actionChanged() which can be redefined in the
+  subclasses to customize reaction on this.
+*/
+void QtxActionMgr::onActionChanged()
+{
+  QAction* a = ::qobject_cast<QAction*>( sender() );
+
+  int id = actionId( a );
+  if ( id != -1 )
+    actionChanged( id );
+}
+
 /*!
   \class QtxActionMgr::Reader
   \brief Generic actions description files reader class.