From: nds Date: Fri, 6 Jun 2014 13:59:38 +0000 (+0400) Subject: refs #80 - Sketch base GUI: create/draw point, circle and arc X-Git-Tag: V_0.4.4~305 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=71932b0379863382b05da9c9e9b12fbc29016a1a;p=modules%2Fshaper.git refs #80 - Sketch base GUI: create/draw point, circle and arc Key release signal is emitted by double value widget in order to bread and restart circle creation operation like it is for line feature. --- diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 6ec34c3ca..0824da5b4 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData) @@ -72,6 +74,8 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, c aControlLay->setStretch(1, 1); connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged())); + + mySpinBox->installEventFilter(this); } ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue() @@ -108,3 +112,14 @@ QList ModuleBase_WidgetDoubleValue::getControls() const aList.append(mySpinBox); return aList; } + +bool ModuleBase_WidgetDoubleValue::eventFilter(QObject *theObject, QEvent *theEvent) +{ + if (theObject == mySpinBox) { + if (theEvent->type() == QEvent::KeyRelease) { + emit keyReleased(attributeID(), (QKeyEvent*) theEvent); + return true; + } + } + return ModuleBase_ModelWidget::eventFilter(theObject, theEvent); +} diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h index 024e12ab7..70f6de58c 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h @@ -38,6 +38,11 @@ public: /// \returns the widget QWidget* getControl() const { return myContainer; } + /// Process key release envent on the widget spin box controls + /// \param theObject the object where the event happens + /// \param theEvent the processed event + virtual bool eventFilter(QObject *theObject, QEvent *theEvent); + private: QWidget* myContainer; QLabel* myLabel; diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.h b/src/ModuleBase/ModuleBase_WidgetPoint2D.h index 4e4dd152f..bb0f7c84d 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.h +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.h @@ -45,6 +45,9 @@ public: /// \return a control list virtual QList getControls() const; + /// Process key release envent on the widget spin box controls + /// \param theObject the object where the event happens + /// \param theEvent the processed event virtual bool eventFilter(QObject *theObject, QEvent *theEvent); private: