X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_ErrorMgr.cpp;h=e360e99716aeefaf3e0de208b83d3a9556f7bfe2;hb=1cef78af4c4328ecf99a3ced86bda38e6e82e15c;hp=afacb5d82e77cb29e1212b3a39dda5e9bdd88961;hpb=34afe547352180006fee9600173c4dc93dc1f6c3;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ErrorMgr.cpp b/src/XGUI/XGUI_ErrorMgr.cpp index afacb5d82..e360e9971 100644 --- a/src/XGUI/XGUI_ErrorMgr.cpp +++ b/src/XGUI/XGUI_ErrorMgr.cpp @@ -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() @@ -55,13 +61,21 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature) (workshop()->operationMgr()->currentOperation()); if (aFOperation && aFOperation->feature() == theFeature) { QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); - QString anError = myWorkshop->module()->getFeatureError(theFeature); - + ModuleBase_ModelWidget* anActiveWidget = activeWidget(); - QString aWidgetError = myWorkshop->module()->getWidgetError(anActiveWidget); - if (anError.isEmpty()) - anError = aWidgetError; - + bool isApplyEnabledByActiveWidget = false; + if (anActiveWidget) + isApplyEnabledByActiveWidget = anActiveWidget->getValueState() == + ModuleBase_ModelWidget::ModifiedInPP; + QString anError = ""; + QString aWidgetError = ""; + if (!isApplyEnabledByActiveWidget) { + anError = myWorkshop->module()->getFeatureError(theFeature); + if (anActiveWidget) + aWidgetError = anActiveWidget->getError(); + if (anError.isEmpty()) + anError = aWidgetError; + } updateActionState(anOkAction, anError); updateToolTip(anActiveWidget, aWidgetError); } @@ -70,16 +84,31 @@ 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); + } +} + +bool XGUI_ErrorMgr::isApplyEnabled() const +{ + bool isEnabled = false; + XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr(); + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (workshop()->operationMgr()->currentOperation()); + if (aFOperation) { + QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); + isEnabled = anOkAction && anOkAction->isEnabled(); } + return isEnabled; } void XGUI_ErrorMgr::updateActionState(QAction* theAction, const QString& theError) @@ -87,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 @@ -101,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); }