From 71932b0379863382b05da9c9e9b12fbc29016a1a Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 6 Jun 2014 17:59:38 +0400 Subject: [PATCH] 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. --- src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp | 15 +++++++++++++++ src/ModuleBase/ModuleBase_WidgetDoubleValue.h | 5 +++++ src/ModuleBase/ModuleBase_WidgetPoint2D.h | 3 +++ 3 files changed, 23 insertions(+) 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: -- 2.39.2