From: nds Date: Tue, 25 Aug 2015 14:06:15 +0000 (+0300) Subject: Synchronize AcceptAll actions state between Tool bar and property panel. X-Git-Tag: V_1.4.0_beta4~248 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3395e370f75b7e2322326dbf2cf99472b14be829;p=modules%2Fshaper.git Synchronize AcceptAll actions state between Tool bar and property panel. Default enabled state of AcceptAll button is disabled. An attempt to update the state on Undo/Redo/Delete sketch feature operations. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 992e821cb..c23c23beb 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -627,6 +627,8 @@ bool PartSet_Module::deleteObjects() // 5. stop operation aWorkshop->displayer()->updateViewer(); aMgr->finishOperation(); + XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr(); + anOpMgr->updateApplyOfOperations(); } else { bool isPartRemoved = false; // Delete part with help of PartSet plugin diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 8cf0c02c1..fd872f417 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -171,6 +171,14 @@ void XGUI_ActionsMgr::updateOnViewSelection() } } +void XGUI_ActionsMgr::onAcceptAllToggled(bool theState) +{ + if (!theState) { + QAction* anAcceptAllAction = operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL); + anAcceptAllAction->setEnabled(theState); + } +} + QKeySequence XGUI_ActionsMgr::registerShortcut(const QKeySequence& theKeySequence) { if (theKeySequence.isEmpty()) { @@ -236,10 +244,9 @@ QAction* XGUI_ActionsMgr::operationStateAction(OperationStateActionId theId, QOb case Accept: case AcceptAll: aResult = new QAction(QIcon(":pictures/button_ok.png"), "", theParent); - // the default value is disabled, some modifications should be performed in order - // to update enable state of this action. - // AcceptAll is blinked when sketch is started from enabled to disabled. - aResult->setEnabled(false); + // the default value is disabled, so the next connect is used to restore this + // default state by untoggle this action + connect(this, SIGNAL(toggled(bool)), this, SLOT(onAcceptAllToggled(bool))); break; case Abort: case AbortAll: { diff --git a/src/XGUI/XGUI_ActionsMgr.h b/src/XGUI/XGUI_ActionsMgr.h index 9191021ad..8be19e49d 100644 --- a/src/XGUI/XGUI_ActionsMgr.h +++ b/src/XGUI/XGUI_ActionsMgr.h @@ -96,6 +96,9 @@ public slots: void updateCheckState(); //! Updates actions according to current selection in the viewer void updateOnViewSelection(); + //! Update the default enable state of the action by untoggle it. The default value is disabled. + //! \param theState the new state of the AcceptAll action + void onAcceptAllToggled(bool theState); protected: //! Sets all actions to isEnabled state. diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 7f6e26b93..4c4514981 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -154,10 +154,12 @@ signals: /// \param theEnabled the state value void setApplyEnabled(const bool theEnabled); +public: // TEMPORARY, it should be protected and be performed automatically /// Emits nestedStateChange for operations with an information about validity of the operation /// \param theOperation the sent operation. If it is NULL, all operations in the stack are sent. void updateApplyOfOperations(ModuleBase_Operation* theOperation = 0); +protected: // TEMPORARY /// Commits the current operatin if it is valid bool commitOperation(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index e08bae76c..a66f44598 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -663,6 +663,8 @@ void XGUI_Workshop::onUndo(int theTimes) for (int i = 0; i < theTimes; ++i) { aMgr->undo(); } + + operationMgr()->updateApplyOfOperations(); updateCommandStatus(); } @@ -686,6 +688,7 @@ void XGUI_Workshop::onRedo(int theTimes) for (int i = 0; i < theTimes; ++i) { aMgr->redo(); } + operationMgr()->updateApplyOfOperations(); updateCommandStatus(); // unblock the viewer update functionality and make update on purpose @@ -1038,6 +1041,7 @@ void XGUI_Workshop::deleteObjects() if (deleteFeatures(anObjects, anIgnoredFeatures, aDesktop, true)) { myDisplayer->updateViewer(); aMgr->finishOperation(); + operationMgr()->updateApplyOfOperations(); updateCommandStatus(); } else {