From ba1f1fb6b1d9660f552a5d862b13955a86ebd988 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 18 Nov 2015 09:52:08 +0300 Subject: [PATCH] SALOME mode: dimension constraint operaion is not restarted by enter in the widget editor. Key release is not emitted and is not processed by operation manager. This is a workaround --- src/ModuleBase/ModuleBase_DoubleSpinBox.cpp | 6 ++++++ src/ModuleBase/ModuleBase_DoubleSpinBox.h | 5 +++++ src/ModuleBase/ModuleBase_WidgetEditor.cpp | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp index 488e8f11c..06c1afcd6 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp @@ -203,18 +203,24 @@ QString ModuleBase_DoubleSpinBox::removeTrailingZeroes(const QString& src) const 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 keyReleased(theEvent); } /*! diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.h b/src/ModuleBase/ModuleBase_DoubleSpinBox.h index f827ba264..ef22f8ad1 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.h +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.h @@ -60,6 +60,11 @@ Q_OBJECT /// \return the previous value bool enableKeyPressEvent(const bool& theEnable); +signals: + /// The signal about key release on the control, that corresponds to the attribute + /// \param theEvent key release event + void keyReleased(QKeyEvent* theEvent); + protected slots: /// Called on text changed virtual void onTextChanged(const QString&); diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.cpp b/src/ModuleBase/ModuleBase_WidgetEditor.cpp index 334c50492..87bb57ff1 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetEditor.cpp @@ -51,6 +51,9 @@ void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText) ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(&aDlg); anEditor->enableKeyPressEvent(true); + if (!myIsEditing) { + connect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); + } anEditor->setMinimum(0); anEditor->setMaximum(DBL_MAX); @@ -67,6 +70,11 @@ void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText) aDlg.move(QCursor::pos()); aDlg.exec(); + + if (!myIsEditing) { + disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); + } + outText = anEditor->text(); bool isDouble; double aValue = outText.toDouble(&isDouble); -- 2.39.2