]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix for bug IPAL18578 (Qt4 porting: Menu - New Entity - Sketch: self activation of...
authormzn <mzn@opencascade.com>
Thu, 27 Mar 2008 07:22:16 +0000 (07:22 +0000)
committermzn <mzn@opencascade.com>
Thu, 27 Mar 2008 07:22:16 +0000 (07:22 +0000)
src/EntityGUI/EntityGUI_SketcherDlg.cxx
src/EntityGUI/EntityGUI_SketcherDlg.h

index 3697c8ead41b5ba1e48db7246a51b9c7030fc70d..2a41dab9757a91130a544ad922660d307225c61b 100644 (file)
@@ -216,27 +216,18 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
 
   connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
   connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
-
-  connect( Group1Spin->SpinBox_DX,  SIGNAL( editingFinished() ),
-          Group1Spin->buttonApply, SLOT( animateClick() ) );
-  connect( Group2Spin->SpinBox_DX,  SIGNAL( editingFinished() ),
-          Group2Spin->buttonApply, SLOT( animateClick() ) );
-  connect( Group2Spin->SpinBox_DY,  SIGNAL( editingFinished() ),
-          Group2Spin->buttonApply, SLOT( animateClick() ) );
-  connect( Group3Spin->SpinBox_DX,  SIGNAL( editingFinished() ),
-          Group3Spin->buttonApply, SLOT( animateClick() ) );
-  connect( Group3Spin->SpinBox_DY,  SIGNAL( editingFinished() ),
-          Group3Spin->buttonApply, SLOT( animateClick() ) );
-  connect( Group3Spin->SpinBox_DZ,  SIGNAL( editingFinished() ),
-          Group3Spin->buttonApply, SLOT( animateClick() ) );
-  connect( Group4Spin->SpinBox_DX,  SIGNAL( editingFinished() ),
-          Group4Spin->buttonApply, SLOT( animateClick() ) );
-  connect( Group4Spin->SpinBox_DY,  SIGNAL( editingFinished() ),
-          Group4Spin->buttonApply, SLOT( animateClick() ) );
-  connect( Group4Spin->SpinBox_DZ,  SIGNAL( editingFinished() ),
-          Group4Spin->buttonApply, SLOT( animateClick() ) );
-  connect( Group4Spin->SpinBox_DS,  SIGNAL( editingFinished() ),
-          Group4Spin->buttonApply, SLOT( animateClick() ) );
+  
+  // install event filter on spin-boxes to provide Apply action on Return pressed
+  Group1Spin->SpinBox_DX->installEventFilter(this);
+  Group2Spin->SpinBox_DX->installEventFilter(this);
+  Group2Spin->SpinBox_DY->installEventFilter(this);
+  Group3Spin->SpinBox_DX->installEventFilter(this);
+  Group3Spin->SpinBox_DY->installEventFilter(this);
+  Group3Spin->SpinBox_DZ->installEventFilter(this);
+  Group4Spin->SpinBox_DX->installEventFilter(this);
+  Group4Spin->SpinBox_DY->installEventFilter(this);
+  Group4Spin->SpinBox_DZ->installEventFilter(this);
+  Group4Spin->SpinBox_DS->installEventFilter(this);
 
   Init();
 }
@@ -252,6 +243,49 @@ EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
 }
 
 
+//=================================================================================
+// function : eventFilter()
+// purpose  : event filter for spin-boxes to provide Apply action on Return pressed
+//=================================================================================
+bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
+{
+  if (event->type() == QEvent::KeyPress) {
+    QKeyEvent* ke = (QKeyEvent*)event;
+    if (ke->key() == Qt::Key_Return) {
+      if (object == Group1Spin->SpinBox_DX) {
+        Group1Spin->buttonApply->animateClick();
+        return true;
+      } else if (object == Group2Spin->SpinBox_DX ||
+                 object == Group2Spin->SpinBox_DY) {
+        Group2Spin->buttonApply->animateClick();
+        return true;
+      } else if (object == Group3Spin->SpinBox_DX ||
+                 object == Group3Spin->SpinBox_DY ||
+                 object == Group3Spin->SpinBox_DZ) {
+        Group3Spin->buttonApply->animateClick();
+        return true;
+      } else if (object == Group4Spin->SpinBox_DX ||
+                 object == Group4Spin->SpinBox_DY ||
+                 object == Group4Spin->SpinBox_DZ ||
+                 object == Group4Spin->SpinBox_DS) {
+        Group4Spin->buttonApply->animateClick();
+        return true;
+      }
+    }
+  }
+
+  if (event->type() == QEvent::KeyRelease) {
+    // NPAL16010 (Sketcher Apply non available if only one line is modified)
+    // To have Apply active as soon as value text changed
+    QDoubleSpinBox* aDoubleSpinBox = (QDoubleSpinBox*)object;
+    if (aDoubleSpinBox)
+      ValueChangedInSpinBox( aDoubleSpinBox->value() );
+  }
+  
+  return QDialog::eventFilter(object, event);
+}
+
+
 //=================================================================================
 // function : Init()
 // purpose  :
@@ -1498,4 +1532,3 @@ void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
   Group4Spin->SpinBox_DZ->setSingleStep(step);
   Group4Spin->SpinBox_DS->setSingleStep(step);
 }
-
index 60fb6a0c7d1abb6d2736590202f4e3c5e571496c..8f5fd48ae7b638921854357e145ff594dd52d195 100644 (file)
@@ -63,6 +63,8 @@ public:
                         const double = 2. );
   ~EntityGUI_SketcherDlg();
 
+  bool eventFilter (QObject* object, QEvent* event);
+
 protected:
   void                               initSpinBox( QDoubleSpinBox*, 
                                                  double, double, double = 0.1,