From 90400ffdc0300c3a01d549b048b1331a79bebc9a Mon Sep 17 00:00:00 2001 From: mzn Date: Thu, 27 Mar 2008 07:22:16 +0000 Subject: [PATCH] Fix for bug IPAL18578 (Qt4 porting: Menu - New Entity - Sketch: self activation of Apply button. Impossible to work). --- src/EntityGUI/EntityGUI_SketcherDlg.cxx | 77 ++++++++++++++++++------- src/EntityGUI/EntityGUI_SketcherDlg.h | 2 + 2 files changed, 57 insertions(+), 22 deletions(-) diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.cxx b/src/EntityGUI/EntityGUI_SketcherDlg.cxx index 3697c8ead..2a41dab97 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_SketcherDlg.cxx @@ -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); } - diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.h b/src/EntityGUI/EntityGUI_SketcherDlg.h index 60fb6a0c7..8f5fd48ae 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.h +++ b/src/EntityGUI/EntityGUI_SketcherDlg.h @@ -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, -- 2.39.2