X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_OperationMgr.cpp;h=8a3b36e12ca8755668b625de5c2f3df25eb958ca;hb=0caee92b045249b15dd6df72d52b44335e05cc3f;hp=3fb2cad89dce5d54dc9705829b0555b0fdc9adb3;hpb=85dac7e3ff9b153e51ccdeca3d28198ba9a36d38;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 3fb2cad89..8a3b36e12 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -46,6 +46,8 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation) connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped())); connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted())); connect(theOperation, SIGNAL(resumed()), this, SIGNAL(operationResumed())); + connect(theOperation, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), + this, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*))); theOperation->start(); return true; @@ -106,10 +108,16 @@ bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation) bool XGUI_OperationMgr::canStopOperation() { - int anAnswer = QMessageBox::question(0, tr("Operation launch"), - tr("Previous operation is not finished and will be aborted"), - QMessageBox::Ok, QMessageBox::Cancel); - return anAnswer == QMessageBox::Ok; + ModuleBase_Operation* anOperation = currentOperation(); + if (anOperation) { + if (anOperation->isModified()) { + int anAnswer = QMessageBox::question(qApp->activeWindow(), tr("Operation launch"), + tr("Previous operation is not finished and will be aborted"), + QMessageBox::Ok, QMessageBox::Cancel); + return anAnswer == QMessageBox::Ok; + } + } + return true; } void XGUI_OperationMgr::onCommitOperation() @@ -122,10 +130,22 @@ void XGUI_OperationMgr::onCommitOperation() void XGUI_OperationMgr::onAbortOperation() { ModuleBase_Operation* anOperation = currentOperation(); - if (anOperation) + if (anOperation && canAbortOperation()) anOperation->abort(); } +bool XGUI_OperationMgr::canAbortOperation() +{ + ModuleBase_Operation* anOperation = currentOperation(); + if (anOperation && anOperation->isModified()) { + int anAnswer = QMessageBox::question(qApp->activeWindow(), tr("Cancel operation"), + tr("Operation %1 will be cancelled. Continue?").arg(anOperation->id()), + QMessageBox::Yes, QMessageBox::No); + return anAnswer == QMessageBox::Yes; + } + return true; +} + void XGUI_OperationMgr::onOperationStopped() { ModuleBase_Operation* aSenderOperation = dynamic_cast(sender()); @@ -160,3 +180,10 @@ void XGUI_OperationMgr::onKeyReleased(const std::string& theName, QKeyEvent* the if (anOperation) anOperation->keyReleased(theName, theEvent); } + +void XGUI_OperationMgr::onWidgetActivated(ModuleBase_ModelWidget* theWidget) +{ + ModuleBase_Operation* anOperation = currentOperation(); + if (anOperation) + anOperation->onWidgetActivated(theWidget); +}