Salome HOME
Merge branch 'Dev_2.1.0' of salome:modules/shaper into Dev_2.1.0
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2dDistance.cpp
index d2f1a08aaef00d9598a035cdfed552b6f627159a..562604dc05578878b5ef62c137adebad2296788b 100644 (file)
@@ -22,8 +22,6 @@
 
 #include <QMouseEvent>
 
-#define APPLY_BY_ENTER_OR_TAB
-
 PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent,
                                                              ModuleBase_IWorkshop* theWorkshop,
                                                              const Config_WidgetAPI* theData,
@@ -31,18 +29,6 @@ PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent,
  : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), myWorkshop(theWorkshop)
 {
   myFirstPntName = theData->getProperty("first_point");
-
-  // Reconnect to local slot
-#ifdef APPLY_BY_ENTER_OR_TAB
-  // Apply widget value change by enter/tab event.
-  //disconnect(mySpinBox, SIGNAL(editingFinished()), this, SIGNAL(valuesChanged()));
-  disconnect(mySpinBox, SIGNAL(valueStored()), this, SIGNAL(valuesChanged()));
-  connect(mySpinBox, SIGNAL(editingFinished()), this, SLOT(onValuesChanged()));
-  connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesModified()));
-#else
-  disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
-  connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
-#endif
 }
 
 PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance()
@@ -109,7 +95,10 @@ void PartSet_WidgetPoint2dDistance::onMouseRelease(ModuleBase_IViewWindow* theWn
 
   std::shared_ptr<GeomAPI_Pnt2d> aPnt = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
   setPoint(feature(), aPnt);
-  emit focusOutWidget(this);
+
+  // if the validator of the control returns false, focus should not be switched
+  if (getError().isEmpty())
+    emit focusOutWidget(this);
 }
 
 void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
@@ -132,17 +121,11 @@ void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd,
   setValueState(ModifiedInViewer);
 }
 
-void PartSet_WidgetPoint2dDistance::onValuesChanged()
-{
-  emit valuesChanged();
-}
-
 bool PartSet_WidgetPoint2dDistance::processEnter()
 {
-  bool isModified = mySpinBox->isModified();
+  bool isModified = getValueState() == ModifiedInPP;
   if (isModified) {
     emit valuesChanged();
-    mySpinBox->clearModified();
     mySpinBox->selectAll();
   }
   return isModified;