Salome HOME
Angle presentation from NewGEOM_2.0.0. It is moved here to prepare a patch for OCCT...
[modules/shaper.git] / src / XGUI / XGUI_ErrorMgr.cpp
index 7156e296fffbb4bb4edfef22b9d78a65dfebad6a..e360e99716aeefaf3e0de208b83d3a9556f7bfe2 100644 (file)
@@ -39,7 +39,13 @@ XGUI_ErrorMgr::XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorksh
     myErrorLabel(0),
     myWorkshop(theWorkshop)
 {
+  ModuleBase_ModelWidget* anActiveWidget = activeWidget();
+  XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
+  QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
+  myAcceptAllToolTip = anAcceptAllAction->toolTip();
 
+  QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
+  myAcceptToolTip = anOkAction->toolTip();
 }
 
 XGUI_ErrorMgr::~XGUI_ErrorMgr()
@@ -65,7 +71,8 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature)
     QString aWidgetError = "";
     if (!isApplyEnabledByActiveWidget) {
       anError = myWorkshop->module()->getFeatureError(theFeature);
-      aWidgetError = myWorkshop->module()->getWidgetError(anActiveWidget);
+      if (anActiveWidget)
+        aWidgetError = anActiveWidget->getError();
       if (anError.isEmpty())
         anError = aWidgetError;
     }
@@ -77,15 +84,17 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature)
 void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature)
 {
   QString anError = myWorkshop->module()->getFeatureError(theFeature);
-  if (anError.isEmpty())
-    anError = myWorkshop->module()->getWidgetError(activeWidget());
-
+  if (anError.isEmpty()) {
+    ModuleBase_ModelWidget* anActiveWidget = activeWidget();
+    if (anActiveWidget)
+      anError = anActiveWidget->getError();
+  }
   XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
   if (workshop()->isFeatureOfNested(theFeature)) {
     QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
     bool anEnabled = anError.isEmpty();
     anAcceptAllAction->setEnabled(anEnabled);
-    anAcceptAllAction->setToolTip(anError);
+    anAcceptAllAction->setToolTip(!anEnabled ? anError : myAcceptAllToolTip);
   }
 }
 
@@ -107,6 +116,7 @@ void XGUI_ErrorMgr::updateActionState(QAction* theAction, const QString& theErro
   bool anEnabled = theError.isEmpty();
 
   theAction->setEnabled(anEnabled);
+  theAction->setToolTip(anEnabled ? myAcceptToolTip : theError);
   // some operations have no property panel, so it is important to check that it is not null
   if (myPropertyPanel) {
     // update controls error information
@@ -121,7 +131,7 @@ void XGUI_ErrorMgr::onWidgetChanged()
   if (!aModelWidget || !aModelWidget->feature().get())
     return;
 
-  QString aWidgetError = myWorkshop->module()->getWidgetError(aModelWidget);
+  QString aWidgetError = aModelWidget->getError();
   updateToolTip(aModelWidget, aWidgetError);
 }