Salome HOME
Issue #2159 Hide all incomplete behavior
[modules/shaper.git] / src / XGUI / XGUI_ErrorMgr.cpp
index 79a7c1ae0a27983326f7bb640b466b0b8789f390..b93c58c09110af825f5282aee538be6906db74c1 100644 (file)
@@ -41,15 +41,12 @@ XGUI_ErrorMgr::XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorksh
   : ModuleBase_IErrorMgr(theParent),
     myErrorDialog(0),
     myErrorLabel(0),
-    myWorkshop(theWorkshop)
+    myWorkshop(theWorkshop),
+    myAcceptAllToolTip(""),
+    myAcceptAllStatusTip(""),
+    myAcceptToolTip(""),
+    myAcceptStatusTip("")
 {
-  ModuleBase_ModelWidget* anActiveWidget = activeWidget();
-  XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
-  QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll);
-  myAcceptAllToolTip = anAcceptAllAction->toolTip();
-
-  QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
-  myAcceptToolTip = anOkAction->toolTip();
 }
 
 XGUI_ErrorMgr::~XGUI_ErrorMgr()
@@ -94,11 +91,20 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature)
 
 void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature)
 {
-  QString anError = myWorkshop->module()->getFeatureError(theFeature);
-  if (anError.isEmpty()) {
-    ModuleBase_ModelWidget* anActiveWidget = activeWidget();
-    if (anActiveWidget)
-      anError = anActiveWidget->getError();
+  if (myAcceptAllToolTip.isEmpty() && myAcceptToolTip.isEmpty())
+    storeInitialActionValues();
+
+  QString anError = "";
+  /// to allow the module have the button always enabled
+  bool isActionStateEnabled =
+    myWorkshop->module()->isActionEnableStateFixed(XGUI_ActionsMgr::AcceptAll);
+  if (!isActionStateEnabled) {
+    anError = myWorkshop->module()->getFeatureError(theFeature);
+    if (anError.isEmpty()) {
+      ModuleBase_ModelWidget* anActiveWidget = activeWidget();
+      if (anActiveWidget)
+        anError = anActiveWidget->getError();
+    }
   }
   XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
   if (workshop()->isFeatureOfNested(theFeature)) {
@@ -106,6 +112,7 @@ void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature)
     bool anEnabled = anError.isEmpty();
     anAcceptAllAction->setEnabled(anEnabled);
     anAcceptAllAction->setToolTip(!anEnabled ? anError : myAcceptAllToolTip);
+    anAcceptAllAction->setStatusTip(!anEnabled ? anError : myAcceptAllStatusTip);
   }
 }
 
@@ -122,15 +129,31 @@ bool XGUI_ErrorMgr::isApplyEnabled() const
   return isEnabled;
 }
 
+void XGUI_ErrorMgr::storeInitialActionValues()
+{
+  ModuleBase_ModelWidget* anActiveWidget = activeWidget();
+  XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
+  QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll);
+  myAcceptAllToolTip = anAcceptAllAction->toolTip();
+  myAcceptAllStatusTip = anAcceptAllAction->statusTip();
+
+  QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
+  myAcceptToolTip = anOkAction->toolTip();
+  myAcceptStatusTip = anOkAction->toolTip();
+}
+
 void XGUI_ErrorMgr::updateAcceptActionState(const QString& theError)
 {
   XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
   QAction* anAcceptAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
 
-  bool anEnabled = theError.isEmpty();
+  if (myAcceptAllToolTip.isEmpty() && myAcceptToolTip.isEmpty())
+    storeInitialActionValues();
 
+  bool anEnabled = theError.isEmpty();
   anAcceptAction->setEnabled(anEnabled);
   anAcceptAction->setToolTip(anEnabled ? myAcceptToolTip : theError);
+  anAcceptAction->setStatusTip(anEnabled ? myAcceptStatusTip : theError);
   // some operations have no property panel, so it is important to check that it is not null
   if (myPropertyPanel) {
     // update controls error information