X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_PropertyPanel.cpp;h=3838f78868d384e056105fdf810ee01a6d28aeef;hb=7bac0ce308b594cf5e682c1153c59ef3507b794c;hp=26ea5d021e587ad4a7a5820c1b3373a5e38bdb2f;hpb=a24b7e6f4d112d5e7889fd76f030298fc428cd01;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 26ea5d021..3838f7886 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -9,6 +9,7 @@ #include #include +#include //#include #include #include @@ -31,10 +32,12 @@ #include #endif -XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) +XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr) : ModuleBase_IPropertyPanel(theParent), myActiveWidget(NULL), - myPanelPage(NULL) + myPreselectionWidget(NULL), + myPanelPage(NULL), + myOperationMgr(theMgr) { this->setWindowTitle(tr("Property Panel")); QAction* aViewAct = this->toggleViewAction(); @@ -55,6 +58,8 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) ModuleBase_Tools::zeroMargins(aBtnLay); aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn); + myHeaderWidget = aFrm; + QStringList aBtnNames; aBtnNames << QString(PROP_PANEL_HELP) << QString(PROP_PANEL_OK) @@ -80,6 +85,22 @@ void XGUI_PropertyPanel::cleanContent() { if (myActiveWidget) myActiveWidget->deactivate(); + + /// as the widgets are deleted later, it is important that the signals + /// of these widgets are not processed. An example of the error is issue 986. + /// In the given case, the property panel is firstly filled by new widgets + /// of restarted operation and after that the mouse release signal come from + /// the widget of the previous operation (Point2d widget about mouse is released + /// and focus is out of this widget) + QList::const_iterator anIt = myWidgets.begin(), + aLast = myWidgets.end(); + for (; anIt != aLast; anIt++) { + QWidget* aWidget = *anIt; + if (aWidget) { + aWidget->blockSignals(true); + } + } + myWidgets.clear(); myPanelPage->clearPage(); myActiveWidget = NULL; @@ -98,19 +119,23 @@ 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); + QWidget* aLastControl = 0; + QList aControls; + for (int i = myWidgets.size()-1; i >= 0 && !aLastControl; i--) { + aControls = myWidgets[i]->getControls(); + for (int j = aControls.size()-1; j >= 0 && !aLastControl; j--) { + if (aControls[j]->focusPolicy() != Qt::NoFocus) + aLastControl = aControls[j]; } } + if (aLastControl) { + QToolButton* anOkBtn = findChild(PROP_PANEL_OK); + QToolButton* aCancelBtn = findChild(PROP_PANEL_CANCEL); + + setTabOrder(aLastControl, anOkBtn); + setTabOrder(anOkBtn, aCancelBtn); + } } const QList& XGUI_PropertyPanel::modelWidgets() const @@ -132,7 +157,8 @@ void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature) if (theFeature->isAction() || !theFeature->data()) return; foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) { - eachWidget->setFeature(theFeature); + if (!eachWidget->feature().get()) + eachWidget->setFeature(theFeature); eachWidget->restoreValue(); } // the repaint is used here to immediately react in GUI to the values change. @@ -146,22 +172,18 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) activateWidget(NULL); return; } - ModuleBase_ModelWidget* aNextWidget = 0; QList::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end(); bool isFoundWidget = false; - for (; anIt != aLast && !aNextWidget; anIt++) { + activateWindow(); + for (; anIt != aLast; anIt++) { if (isFoundWidget || !theWidget) { if ((*anIt)->focusTo()) { - aNextWidget = *anIt; + return; } } - isFoundWidget = (*anIt) == theWidget; - } - // Normaly focusTo is enough to activate widget - // here is a special case on mouse click in the viewer - if(aNextWidget == NULL) { - activateWidget(aNextWidget); + isFoundWidget = isFoundWidget || (*anIt) == theWidget; } + activateWidget(NULL); } void XGUI_PropertyPanel::activateNextWidget() @@ -189,9 +211,16 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) emit widgetActivated(theWidget); } else if (!isEditingMode()) { emit noMoreWidgets(); + setFocusOnOkButton(); } } +void XGUI_PropertyPanel::setFocusOnOkButton() +{ + QToolButton* anOkBtn = findChild(PROP_PANEL_OK); + anOkBtn->setFocus(); +} + void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled) { QToolButton* anCancelBtn = findChild(PROP_PANEL_CANCEL); @@ -224,3 +253,27 @@ void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr) aBtn->setDefaultAction(anAct); } } + +ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const +{ + return myPreselectionWidget; +} + +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); +} \ No newline at end of file