+ bool isAccepted = false;
+ switch (theEvent->key()) {
+ case Qt::Key_Escape: {
+ // processing in message box
+ if (myActiveMessageBox)
+ {
+ myActiveMessageBox->reject();
+ isAccepted = true;
+ }
+ // processing in the active widget
+ ModuleBase_Operation* aOperation = currentOperation();
+ if (!isAccepted && aOperation) {
+ ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
+ if (anActiveWgt)
+ {
+ isAccepted = anActiveWgt && anActiveWgt->processAction(ActionEscape);
+ if (isAccepted) {
+ ModuleBase_OperationFeature* aFOperation =
+ dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
+ if (aFOperation)
+ aFOperation->setNeedToBeAborted(true);
+ }
+ }
+ }
+ if (!isAccepted)
+ {
+ XGUI_ActiveControlSelector* anActiveSelector =
+ XGUI_Tools::workshop(myWorkshop)->activeControlMgr()->activeSelector();
+ if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
+ isAccepted = XGUI_Tools::workshop(myWorkshop)->facesPanel()->processAction(ActionEscape);
+ }
+ // default Escape button functionality
+ if (!isAccepted && aOperation) {
+ onAbortOperation();
+ isAccepted = true;
+ }
+ }
+ break;
+ }
+ return isAccepted;
+}
+
+bool XGUI_OperationMgr::onProcessEnter(QObject* theObject)
+{
+ bool isAccepted = false;
+ ModuleBase_Operation* aOperation = currentOperation();
+ // to avoid enter processing when operation has not been started yet
+ if (!aOperation)
+ return isAccepted;
+ ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ if (!aPanel)
+ return isAccepted;
+ // the next code is obsolete as we want to process Enter in property panel always
+ // only property panel enter is processed in order to do not process enter in application dialogs
+ //bool isPPChild = isChildObject(theObject, aPanel);
+ //if (!isPPChild)
+ // return isAccepted;
+
+ ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
+ bool isAborted = false;
+ if (!anActiveWgt) {
+ QWidget* aFocusWidget = aPanel->focusWidget();
+ QToolButton* aCancelBtn =
+ dynamic_cast<XGUI_PropertyPanel*>(aPanel)->findButton(PROP_PANEL_CANCEL);
+ if (aFocusWidget && aCancelBtn && aFocusWidget == aCancelBtn) {
+ abortOperation(aOperation);
+ isAccepted = true;
+ isAborted = true;
+ }
+ }
+ if (!isAborted) {
+ isAccepted = anActiveWgt && anActiveWgt->processAction(ActionEnter);
+ if (!isAccepted) {
+ isAccepted =
+ myWorkshop->module()->processEnter(anActiveWgt ? anActiveWgt->attributeID() : "");
+ if (!isAccepted) {
+ /// functionality is similar to Apply click
+ ModuleBase_OperationFeature* aFOperation =
+ dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
+ if (!aFOperation ||
+ myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
+ // key released is emitted to apply the current value to the model
+ // if it was modified in PP
+ emit keyEnterReleased();
+ commitOperation();
+ isAccepted = true;
+ }
+ else
+ isAccepted = false;
+ }
+ }
+ }
+ return isAccepted;
+}
+
+bool editorControl(QObject* theObject)
+{
+ QLineEdit* aLineEdit = dynamic_cast<QLineEdit*>(theObject);
+ return aLineEdit;
+}
+
+bool XGUI_OperationMgr::onProcessDelete(QObject* theObject)
+{
+ bool isAccepted = false;
+ ModuleBase_Operation* aOperation = currentOperation();
+ ModuleBase_ModelWidget* anActiveWgt = 0;
+ // firstly the widget should process Delete action
+ ModuleBase_IPropertyPanel* aPanel;
+ bool isPPChildObject = false;
+ if (aOperation) {
+ aPanel = aOperation->propertyPanel();
+ if (aPanel) {
+ isPPChildObject = isChildObject(theObject, aPanel);
+ // process delete in active widget only if delete sender is child of property panel
+ // it is necessary for the case when OB is shown, user perform selection and click Delete
+ if (isPPChildObject) {
+ anActiveWgt = aPanel->activeWidget();
+ if (anActiveWgt) {
+ isAccepted = anActiveWgt->processAction(ActionDelete);
+ }
+ }
+ }
+ }
+ if (!isAccepted)
+ {
+ XGUI_ActiveControlSelector* anActiveSelector =
+ XGUI_Tools::workshop(myWorkshop)->activeControlMgr()->activeSelector();
+ if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
+ isAccepted = XGUI_Tools::workshop(myWorkshop)->facesPanel()->processAction(ActionDelete);
+ }
+ if (!isAccepted) {
+ // after widget, object browser and viewer should process delete
+ /// other widgets such as line edit controls should not lead to
+ /// processing delete by workshop
+ XGUI_ObjectsBrowser* aBrowser = XGUI_Tools::workshop(myWorkshop)->objectBrowser();
+ QWidget* aViewPort = myWorkshop->viewer()->activeViewPort();
+ bool isToDeleteObject = false;
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
+ XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
+ if (theObject == aBrowser->treeView()) {
+ aContextMenuMgr->updateObjectBrowserMenu();
+ isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
+ }
+ else if (isChildObject(theObject, aViewPort)) {
+ aContextMenuMgr->updateViewerMenu();
+ isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
+ }
+ else if (isPPChildObject) {
+ // property panel child object is processed to process delete performed on Apply button of PP
+ isToDeleteObject = true;
+ }
+ else if (editorControl(theObject)) {
+ isToDeleteObject = false; /// Line Edit of Rename operation in ObjectBrowser
+ isAccepted = true;
+ }
+
+ if (isToDeleteObject) {
+ aWorkshop->deleteObjects();
+ isAccepted = true;
+ }
+ }
+
+ return isAccepted;
+}
+
+bool XGUI_OperationMgr::isChildObject(const QObject* theObject, const QObject* theParent)
+{
+ bool isPPChild = false;
+ if (theParent && theObject) {
+ QObject* aParent = (QObject*)theObject;
+ while (aParent ) {
+ isPPChild = aParent == theParent;
+ if (isPPChild)
+ break;
+ aParent = aParent->parent();
+ }
+ }
+ return isPPChild;
+}
+
+QMessageBox* XGUI_OperationMgr::createMessageBox(const QString& theMessage)
+{
+ QMessageBox * aMessageBox = new QMessageBox(QMessageBox::Question,
+ QObject::tr("Abort operation"), theMessage, QMessageBox::Ok | QMessageBox::Cancel,
+ qApp->activeWindow());
+ aMessageBox->setDefaultButton(QMessageBox::Cancel);
+ aMessageBox->setEscapeButton(QMessageBox::No); // operation manager should process Esc key
+
+ return aMessageBox;
+}
+
+QMessageBox* XGUI_OperationMgr::createInformationBox(const QString& theMessage)
+{
+ QMessageBox * aMessageBox = new QMessageBox(QMessageBox::Question,
+ QObject::tr("Validate operation"), theMessage, QMessageBox::Ok,
+ qApp->activeWindow());
+ aMessageBox->setDefaultButton(QMessageBox::Ok);
+ aMessageBox->setEscapeButton(QMessageBox::No); // operation manager should process Esc key
+
+ return aMessageBox;