Salome HOME
Issue #1015: The validate icon must be greyed and inactive instead of red and active
authornds <nds@opencascade.com>
Wed, 25 May 2016 06:53:59 +0000 (09:53 +0300)
committernds <nds@opencascade.com>
Wed, 25 May 2016 06:53:59 +0000 (09:53 +0300)
Popup menu actions upper parent should be the main application to have visible status tip information in status bar

src/XGUI/XGUI_ErrorMgr.cpp
src/XGUI/XGUI_ErrorMgr.h

index 84b2c90a595d8d8cfa7df8a6813b39d2405c9d05..b2a1a87f9f9e1b2ab0640196280da0dc5da51d37 100644 (file)
@@ -41,17 +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();
-  myAcceptAllStatusTip = anAcceptAllAction->statusTip();
-
-  QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
-  myAcceptToolTip = anOkAction->toolTip();
-  myAcceptStatusTip = anOkAction->toolTip();
 }
 
 XGUI_ErrorMgr::~XGUI_ErrorMgr()
@@ -96,6 +91,9 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature)
 
 void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature)
 {
+  if (myAcceptAllToolTip.isEmpty() && myAcceptToolTip.isEmpty())
+    storeInitialActionValues();
+
   QString anError = myWorkshop->module()->getFeatureError(theFeature);
   if (anError.isEmpty()) {
     ModuleBase_ModelWidget* anActiveWidget = activeWidget();
@@ -125,13 +123,28 @@ 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);
index b37b8ecac6884c4b6d2627b61b69386f9accab95..3a320c4b0e807877a5c53b532230a6a78f504ca8 100644 (file)
@@ -52,6 +52,9 @@ protected slots:
   virtual void onWidgetChanged();
 
 private:
+  /// Stores initial values of accept/accept all tool/status tip to internal containers
+  void storeInitialActionValues();
+
   /// It disables the propety panel Accept action if the error message is not empty
   /// The message is set to the header tool tip.
   /// \param theAction an action to be changed