X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_PropertyPanel.cpp;h=f447f24a20aa9cbdf610048ed72e2b2541ce1d45;hb=57626695d1a88caac8e7940758a8ba93a8bcc9c2;hp=ab7695723b537203d7a3f62b8c002fdf9398c5bd;hpb=83e85cedfb936e7755500322e1afa638d318a863;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp old mode 100644 new mode 100755 index ab7695723..f447f24a2 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -9,6 +9,7 @@ #include #include +#include //#include #include #include @@ -31,11 +32,12 @@ #include #endif -XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) +XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr) : ModuleBase_IPropertyPanel(theParent), myActiveWidget(NULL), myPreselectionWidget(NULL), - myPanelPage(NULL) + myPanelPage(NULL), + myOperationMgr(theMgr) { this->setWindowTitle(tr("Property Panel")); QAction* aViewAct = this->toggleViewAction(); @@ -117,19 +119,6 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); } - ModuleBase_ModelWidget* aLastWidget = theWidgets.last(); - if (aLastWidget) { - QList aControls = aLastWidget->getControls(); - if (!aControls.empty()) { - QWidget* aLastControl = aControls.last(); - - QToolButton* anOkBtn = findChild(PROP_PANEL_OK); - QToolButton* aCancelBtn = findChild(PROP_PANEL_CANCEL); - - setTabOrder(aLastControl, anOkBtn); - setTabOrder(anOkBtn, aCancelBtn); - } - } } const QList& XGUI_PropertyPanel::modelWidgets() const @@ -139,7 +128,6 @@ const QList& XGUI_PropertyPanel::modelWidgets() const ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget() { - return static_cast(myPanelPage); } @@ -175,21 +163,92 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) return; } } - isFoundWidget = (*anIt) == theWidget; + isFoundWidget = isFoundWidget || (*anIt) == theWidget; } activateWidget(NULL); } +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) + aFirstControl->setFocus(); + 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) + aLastControl->setFocus(); + 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); + aCancelBtn->setFocus(); + isChangedFocus = true; + } + } + } + + if (!isChangedFocus) + isChangedFocus = ModuleBase_IPropertyPanel::focusNextPrevChild(theIsNext); + + return isChangedFocus; +} + void XGUI_PropertyPanel::activateNextWidget() { activateNextWidget(myActiveWidget); } void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) +{ + // Avoid activation of already actve widget. It could happen on focusIn event many times + if (setActiveWidget(theWidget)) { + if (myActiveWidget) { + emit widgetActivated(myActiveWidget); + } else if (!isEditingMode()) { + emit noMoreWidgets(); + //setFocusOnOkButton(); + } + } +} + +bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget) { // Avoid activation of already actve widget. It could happen on focusIn event many times if (theWidget == myActiveWidget) { - return; + return false; } if(myActiveWidget) { myActiveWidget->deactivate(); @@ -201,11 +260,7 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) theWidget->activate(); } myActiveWidget = theWidget; - if (myActiveWidget) { - emit widgetActivated(theWidget); - } else if (!isEditingMode()) { - emit noMoreWidgets(); - } + return true; } void XGUI_PropertyPanel::setFocusOnOkButton() @@ -256,3 +311,17 @@ void XGUI_PropertyPanel::setPreselectionWidget(ModuleBase_ModelWidget* theWidget { myPreselectionWidget = theWidget; } + + +void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent) +{ + ModuleBase_Operation* aOp = myOperationMgr->currentOperation(); + if (aOp) { + if (myOperationMgr->canStopOperation(aOp)) { + myOperationMgr->abortAllOperations(); + theEvent->accept(); + } else + theEvent->ignore(); + } else + ModuleBase_IPropertyPanel::closeEvent(theEvent); +}