From: nds Date: Sat, 26 Dec 2015 16:47:21 +0000 (+0300) Subject: #1189 Tab - Cancel - Enter validate not cancel X-Git-Tag: V_2.1.0~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c6d14d2a20ee81e36d7d8b2245b50c7767bc03ac;p=modules%2Fshaper.git #1189 Tab - Cancel - Enter validate not cancel --- diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index c04847d5f..d491b9a57 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -25,6 +25,8 @@ #include #include +#include + PartSet_SketcherReetntrantMgr::PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop) : QObject(theWorkshop), myWorkshop(theWorkshop), @@ -324,9 +326,18 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev aPreviousAttributeWidget = aWidgets[i]; } // If the current widget is a selector, do nothing, it processes the mouse press - if (aPreviousAttributeWidget && !aPreviousAttributeWidget->isViewerSelector()) { - aPreviousAttributeWidget->focusTo(); - aPreviousAttributeWidget->selectContent(); + if (aPreviousAttributeWidget) { + if (!aPreviousAttributeWidget->isViewerSelector()) { + aPreviousAttributeWidget->focusTo(); + aPreviousAttributeWidget->selectContent(); + } + else { + // if there is no the next widget to be automatically activated, the Ok button in property + // panel should accept the focus(example is parallel constraint on sketch lines) + QToolButton* anOkBtn = aPanel->findChild(PROP_PANEL_OK); + if (anOkBtn) + anOkBtn->setFocus(Qt::TabFocusReason); + } } } } diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index b8bc93c95..15f90b947 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -22,6 +22,9 @@ #include "ModelAPI_CompositeFeature.h" #include "ModelAPI_Session.h" +#include +#include + #include #include #include @@ -540,15 +543,26 @@ bool XGUI_OperationMgr::onProcessEnter() ModuleBase_Operation* aOperation = currentOperation(); ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget(); - if (!aActiveWgt || !aActiveWgt->processEnter()) { - if (!myWorkshop->module()->processEnter(aActiveWgt ? aActiveWgt->attributeID() : "")) { - ModuleBase_OperationFeature* aFOperation = dynamic_cast(currentOperation()); - if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) { - emit keyEnterReleased(); - commitOperation(); + bool isAborted = false; + if (!aActiveWgt) { + QWidget* aFocusWidget = aPanel->focusWidget(); + QToolButton* aCancelBtn = aPanel->findChild(PROP_PANEL_CANCEL); + if (aFocusWidget && aCancelBtn && aFocusWidget == aCancelBtn) { + abortOperation(aOperation); + isAborted = true; + } + } + if (!isAborted) { + if (!aActiveWgt || !aActiveWgt->processEnter()) { + if (!myWorkshop->module()->processEnter(aActiveWgt ? aActiveWgt->attributeID() : "")) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast(currentOperation()); + if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) { + emit keyEnterReleased(); + commitOperation(); + } + else + isAccepted = false; } - else - isAccepted = false; } } return isAccepted; diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 3e7db245c..2902755d4 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -35,6 +35,8 @@ #include #endif +//#define DEBUG_TAB_WIDGETS + XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr) : ModuleBase_IPropertyPanel(theParent), myActiveWidget(NULL), @@ -208,17 +210,8 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget, isFoundWidget = isFoundWidget || (*anIt) == theWidget; } activateWidget(NULL); - // if there is no the next widget to be automatically activated, the Ok button in property - // panel should accept the focus(example is parallel constraint on sketch lines) - QToolButton* anOkBtn = findChild(PROP_PANEL_OK); - if (anOkBtn) - anOkBtn->setFocus(Qt::TabFocusReason); } -//#define DEBUG_TAB_WIDGETS - -#define DEBUG_TAB -#ifdef DEBUG_TAB void findDirectChildren(QWidget* theParent, QList& theWidgets, const bool theDebug) { QList aWidgets; @@ -320,65 +313,7 @@ bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext) } return isChangedFocus; } -#else -bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext) -{ - // it wraps the Tabs clicking to follow in the chain: - // controls, last control, Apply, Cancel, first control, controls - bool isChangedFocus = false; - if (theIsNext) { // forward by Tab - QToolButton* aCancelBtn = findChild(PROP_PANEL_CANCEL); - if (aCancelBtn->hasFocus()) { - // after cancel, the first control should be focused - QWidget* aFirstControl = 0; - for (int i = 0, aSize = myWidgets.size(); i < aSize && !aFirstControl; i++) - aFirstControl = myWidgets[i]->getControlAcceptingFocus(true); - if (aFirstControl) - ModuleBase_Tools::setFocus(aFirstControl, "XGUI_PropertyPanel::focusNextPrevChild()"); - isChangedFocus = true; - } - else { - // after the last control, the Apply button should be focused - QWidget* aLastControl = 0; - for (int i = myWidgets.size()-1; i >= 0 && !aLastControl; i--) - aLastControl = myWidgets[i]->getControlAcceptingFocus(false); - if (aLastControl && aLastControl->hasFocus()) { - setFocusOnOkButton(); - isChangedFocus = true; - } - } - } - else { // backward by SHIFT + Tab - QToolButton* anOkBtn = findChild(PROP_PANEL_OK); - if (anOkBtn->hasFocus()) { - // after Apply, the last control should be focused - QWidget* aLastControl = 0; - for (int i = myWidgets.size()-1; i >= 0 && !aLastControl; i--) - aLastControl = myWidgets[i]->getControlAcceptingFocus(false); - if (aLastControl) - ModuleBase_Tools::setFocus(aLastControl, "XGUI_PropertyPanel::focusNextPrevChild()"); - isChangedFocus = true; - } - else { - // after the first control, the Cancel button should be focused - QWidget* aFirstControl = 0; - for (int i = 0, aSize = myWidgets.size(); i < aSize && !aFirstControl; i++) - aFirstControl = myWidgets[i]->getControlAcceptingFocus(true); - if (aFirstControl && aFirstControl->hasFocus()) { - QToolButton* aCancelBtn = findChild(PROP_PANEL_CANCEL); - ModuleBase_Tools::setFocus(aCancelBtn, "XGUI_PropertyPanel::focusNextPrevChild()"); - isChangedFocus = true; - } - } - } - - if (!isChangedFocus) - isChangedFocus = ModuleBase_IPropertyPanel::focusNextPrevChild(theIsNext); - return isChangedFocus; -} - -#endif void XGUI_PropertyPanel::activateNextWidget() { activateNextWidget(myActiveWidget);