Salome HOME
Merge branch 'V8_3_asterstudy' into V8_3_BR
[modules/gui.git] / src / Qtx / QtxActionMgr.cxx
index 528ae83491e4f08a56c60ee922755e7e8d43d049..9fb7bb6ad49a3ab03d480ff48c059914ccc46fec 100644 (file)
@@ -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.