Salome HOME
The flushCreated/flushUpdated are obsolete and nobody uses them.
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetEditor.cpp
index 6f32c7606bba64efe3d4c8b9685bd751c90e83d3..07c59651de695bdd6de1d735644fe43719c550b2 100644 (file)
@@ -1,9 +1,12 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetEditor.cpp
 // Created:     25 Apr 2014
 // Author:      Natalia ERMOLAEVA
 
 #include <ModuleBase_WidgetEditor.h>
 #include <ModuleBase_DoubleSpinBox.h>
+#include <ModuleBase_Tools.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -23,6 +26,7 @@
 #include <QTimer>
 #include <QDialog>
 #include <QLayout>
+#include <QApplication>
 
 ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
                                                  const Config_WidgetAPI* theData,
@@ -40,7 +44,7 @@ double editedValue(double theValue, bool& isDone)
   QDialog aDlg;
   aDlg.setWindowFlags(Qt::FramelessWindowHint);
   QHBoxLayout* aLay = new QHBoxLayout(&aDlg);
-  aLay->setContentsMargins(0, 0, 0, 0);
+  ModuleBase_Tools::zeroMargins(aLay);
 
   QLineEdit* aEditor = new QLineEdit(QString::number(theValue), &aDlg);
   aEditor->setValidator(new QDoubleValidator(aEditor));
@@ -59,19 +63,25 @@ double editedValue(double theValue, bool& isDone)
 
 bool ModuleBase_WidgetEditor::focusTo()
 {
+  // We can not launch here modal process for value editing because 
+  // it can be called on other focusOutWidget event and will block it
+  QTimer::singleShot(1, this, SLOT(showPopupEditor()));
+  return true;
+}
+
+void ModuleBase_WidgetEditor::showPopupEditor()
+{
+  // White while all events will be processed
+  QApplication::processEvents();
   double aValue = mySpinBox->value();
   bool isDone;
   aValue = editedValue(aValue, isDone);
 
   if (isDone) {
-    bool isBlocked = mySpinBox->blockSignals(true);
-    mySpinBox->setValue(aValue);
-    mySpinBox->blockSignals(isBlocked);
+    ModuleBase_Tools::setSpinValue(mySpinBox, aValue);
   }
   emit valuesChanged();
   emit focusOutWidget(this);
-
-  return false;
 }
 
 void ModuleBase_WidgetEditor::editFeatureValue(FeaturePtr theFeature,