From: nds Date: Mon, 2 Jun 2014 06:19:43 +0000 (+0400) Subject: refs #46 - define line segment using dialog fileds X-Git-Tag: V_0.4.4~336^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f7c89f34184c18a557cac65165c77d0f87421bb1;p=modules%2Fshaper.git refs #46 - define line segment using dialog fileds Set cursor to the first widget in the property panel. For line creation signal is emitted during start, but, the property panel is built after the operation is stopped and this information do not go to the first point control. --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 57b75346a..afdc1f2ca 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -38,9 +38,12 @@ public: virtual bool restoreValue(boost::shared_ptr theFeature) = 0; - /// Set focus to the current widget if it corresponds to the given attribute + /// Returns whether the widget can accept focus, or if it corresponds to the given attribute /// \param theAttribute name - virtual bool focusTo(const std::string& theAttributeName) = 0; + virtual bool canFocusTo(const std::string& theAttributeName) = 0; + + /// Set focus to the current widget if it corresponds to the given attribute + virtual void focusTo() = 0; /// Returns list of widget controls /// \return a control list diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index 0f397b101..cbc61430a 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -95,16 +95,15 @@ bool ModuleBase_WidgetPoint2D::restoreValue(boost::shared_ptr return true; } -bool ModuleBase_WidgetPoint2D::focusTo(const std::string& theAttributeName) +bool ModuleBase_WidgetPoint2D::canFocusTo(const std::string& theAttributeName) { - if (theAttributeName != myFeatureAttributeID) - return false; + return theAttributeName == myFeatureAttributeID; +} - if (!myXSpin->hasFocus() && !myYSpin->hasFocus()) { +void ModuleBase_WidgetPoint2D::focusTo() +{ + if (!myXSpin->hasFocus() && !myYSpin->hasFocus()) myXSpin->setFocus(); - } - - return true; } QWidget* ModuleBase_WidgetPoint2D::getControl() const diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.h b/src/ModuleBase/ModuleBase_WidgetPoint2D.h index 016b17217..1a09516b0 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.h +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.h @@ -38,9 +38,12 @@ public: virtual bool restoreValue(boost::shared_ptr theFeature); - /// Set focus to the current widget if it corresponds to the given attribute + /// Returns whether the widget can accept focus, or if it corresponds to the given attribute /// \param theAttribute name - virtual bool focusTo(const std::string& theAttributeName); + virtual bool canFocusTo(const std::string& theAttributeName); + + /// Set focus to the current widget if it corresponds to the given attribute + virtual void focusTo(); /// Returns the internal parent wiget control, that can be shown anywhere /// \returns the widget diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index f9328b5e1..f511a5750 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -73,7 +73,6 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t myWidgets = theWidgets; if (!theWidgets.empty()) { - QList::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end(); for (; anIt != aLast; anIt++) { connect(*anIt, SIGNAL(keyReleased(const std::string&, QKeyEvent*)), @@ -92,6 +91,9 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t setTabOrder(anOkBtn, aCancelBtn); } } + ModuleBase_ModelWidget* aWidget = theWidgets.first(); + if (aWidget) + aWidget->focusTo(); } } @@ -138,8 +140,10 @@ void XGUI_PropertyPanel::onFocusActivated(const std::string& theAttributeName) } else { foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) { - if (eachWidget->focusTo(theAttributeName)) + if (eachWidget->canFocusTo(theAttributeName)) { + eachWidget->focusTo(); break; + } } } }