From: nds Date: Fri, 16 May 2014 15:51:55 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~50 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f5ec1838c04da950e166c41f6a7661d8ff62137c;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines It is important to connect to the operation manager to avoid double commit() for all connected operations (sketch, line are connected if apply is pressed in the top sketch line creation operation) --- diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 00419c692..792d58467 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -87,6 +87,20 @@ bool XGUI_OperationMgr::canStopOperation() return anAnswer == QMessageBox::Ok; } +void XGUI_OperationMgr::onCommitOperation() +{ + ModuleBase_Operation* anOperation = currentOperation(); + if (anOperation) + anOperation->commit(); +} + +void XGUI_OperationMgr::onAbortOperation() +{ + ModuleBase_Operation* anOperation = currentOperation(); + if (anOperation) + anOperation->abort(); +} + void XGUI_OperationMgr::onOperationStopped() { ModuleBase_Operation* aSenderOperation = dynamic_cast(sender()); diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 41323570e..d57ca5cca 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -70,6 +70,11 @@ protected: bool canStopOperation(); protected slots: + /// Slot that commits the current operation. + void onCommitOperation(); + /// Slot that aborts the current operation. + void onAbortOperation(); + /// Slot that is called by an operation stop. Removes the stopped operation form the stack. /// If there is a suspended operation, restart it. void onOperationStopped(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 9b391a44e..7298f0aef 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -336,11 +336,6 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage) */ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation) { - QPushButton* aOkBtn = myPropertyPanel->findChild(XGUI::PROP_PANEL_OK); - connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit())); - QPushButton* aCancelBtn = myPropertyPanel->findChild(XGUI::PROP_PANEL_CANCEL); - connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort())); - QAction* aCommand = 0; if (isSalomeMode()) { aCommand = salomeConnector()->command(theOperation->getDescription()->operationId()); @@ -629,6 +624,11 @@ void XGUI_Workshop::createDockWidgets() hidePropertyPanel(); //tabifyDockWidget(aObjDock, myPropertyPanel); + + QPushButton* aOkBtn = myPropertyPanel->findChild(XGUI::PROP_PANEL_OK); + connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation())); + QPushButton* aCancelBtn = myPropertyPanel->findChild(XGUI::PROP_PANEL_CANCEL); + connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation())); } //******************************************************