#include <XGUI_OperationMgr.h>
#include <XGUI_PropertyPanel.h>
+#include <QToolButton>
+
PartSet_SketcherReetntrantMgr::PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop)
: QObject(theWorkshop),
myWorkshop(theWorkshop),
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<QToolButton*>(PROP_PANEL_OK);
+ if (anOkBtn)
+ anOkBtn->setFocus(Qt::TabFocusReason);
+ }
}
}
}
#include "ModelAPI_CompositeFeature.h"
#include "ModelAPI_Session.h"
+#include <XGUI_PropertyPanel.h>
+#include <QToolButton>
+
#include <QMessageBox>
#include <QApplication>
#include <QKeyEvent>
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<ModuleBase_OperationFeature*>(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<QToolButton*>(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<ModuleBase_OperationFeature*>(currentOperation());
+ if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
+ emit keyEnterReleased();
+ commitOperation();
+ }
+ else
+ isAccepted = false;
}
- else
- isAccepted = false;
}
}
return isAccepted;
#include <iostream>
#endif
+//#define DEBUG_TAB_WIDGETS
+
XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr)
: ModuleBase_IPropertyPanel(theParent),
myActiveWidget(NULL),
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<QToolButton*>(PROP_PANEL_OK);
- if (anOkBtn)
- anOkBtn->setFocus(Qt::TabFocusReason);
}
-//#define DEBUG_TAB_WIDGETS
-
-#define DEBUG_TAB
-#ifdef DEBUG_TAB
void findDirectChildren(QWidget* theParent, QList<QWidget*>& theWidgets, const bool theDebug)
{
QList<QWidget*> aWidgets;
}
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<QToolButton*>(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<QToolButton*>(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<QToolButton*>(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);