X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_DoubleSpinBox.cpp;h=851a74834d659b00d26f77acbe345396c217c0d6;hb=450d1bd65c11870d3942a30164518037b9a7503e;hp=080138f5483b0314722ba314cb4c0ed73a4b7a93;hpb=b263f22d52ccb191c4fad8f7455d9714a3024514;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp index 080138f54..851a74834 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -57,7 +58,8 @@ const double PSEUDO_ZERO = 1.e-20; */ ModuleBase_DoubleSpinBox::ModuleBase_DoubleSpinBox(QWidget* theParent, int thePrecision) : QDoubleSpinBox(theParent), - myCleared(false) + myCleared(false), + myIsEmitKeyPressEvent(false) { // VSR 01/07/2010: Disable thousands separator for spin box // (to avoid inconsistency of double-2-string and string-2-double conversion) @@ -196,6 +198,48 @@ QString ModuleBase_DoubleSpinBox::removeTrailingZeroes(const QString& src) const return res; } +void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent* theEvent) +{ + bool isEmitKeyRelease = false; + switch (theEvent->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + // do not react to the Enter key, the property panel processes it + if (!myIsEmitKeyPressEvent) + return; + else + isEmitKeyRelease = true; + } + break; + default: + break; + } + QDoubleSpinBox::keyPressEvent(theEvent); + + if (isEmitKeyRelease) + emit enterPressed(); +} + +void ModuleBase_DoubleSpinBox::keyReleaseEvent(QKeyEvent* theEvent) +{ + switch (theEvent->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + // the enter has already been processed when key is pressed, + // key release should not be processed in operation manager + if (myIsEmitKeyPressEvent) { + theEvent->accept(); + emit enterReleased(); + return; + } + } + break; + default: + break; + } + QDoubleSpinBox::keyReleaseEvent(theEvent); +} + /*! \brief Perform \a steps increment/decrement steps. @@ -307,3 +351,11 @@ void ModuleBase_DoubleSpinBox::onTextChanged(const QString& ) { myCleared = false; } + +bool ModuleBase_DoubleSpinBox::enableKeyPressEvent(const bool& theEnable) +{ + bool aPreviousValue = myIsEmitKeyPressEvent; + myIsEmitKeyPressEvent = theEnable; + + return aPreviousValue; +}