X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_OperationMgr.cpp;h=514c5b2f116c1f760e975a7dbc1f86efb86bda20;hb=a3b2736968186ac435b1e05e530c40becbc82301;hp=2a27188c9e9447073a6147681c192c4fe67bcc04;hpb=a993a2e680b4a5a2e8b9ad9c998dc872ff962702;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 2a27188c9..514c5b2f1 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -7,10 +7,14 @@ #include "ModuleBase_Operation.h" #include +#include +#include XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent) : QObject(theParent) { + // listen to Escape signal to stop the current operation + qApp->installEventFilter(this); } XGUI_OperationMgr::~XGUI_OperationMgr() @@ -66,6 +70,20 @@ QStringList XGUI_OperationMgr::operationList() return result; } +bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent) +{ + if (theEvent->type() == QEvent::KeyRelease) { + QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent; + if (aKeyEvent && aKeyEvent->key() == Qt::Key_Escape) { + // TODO: this is Escape button processing when the property panel has empty content, + // but the operation should be stopped by the Enter has been clicked + onKeyReleased("", aKeyEvent); + return true; + } + } + return QObject::eventFilter(theObject, theEvent); +} + void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation) { theOperation->resume(); @@ -97,8 +115,12 @@ bool XGUI_OperationMgr::canStopOperation() void XGUI_OperationMgr::onCommitOperation() { ModuleBase_Operation* anOperation = currentOperation(); - if (anOperation) - anOperation->commit(); + if (anOperation) { + if (anOperation->canBeCommitted()) + anOperation->commit(); + else + anOperation->abort(); + } } void XGUI_OperationMgr::onAbortOperation() @@ -135,3 +157,10 @@ void XGUI_OperationMgr::onOperationStopped() if (aResultOp) resumeOperation(aResultOp); } + +void XGUI_OperationMgr::onKeyReleased(const std::string& theName, QKeyEvent* theEvent) +{ + ModuleBase_Operation* anOperation = currentOperation(); + if (anOperation) + anOperation->keyReleased(theName, theEvent); +}