From: nds Date: Wed, 18 Nov 2015 06:52:08 +0000 (+0300) Subject: SALOME mode: dimension constraint operaion is not restarted by enter in the widget... X-Git-Tag: V_2.0.0~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ba1f1fb6b1d9660f552a5d862b13955a86ebd988;p=modules%2Fshaper.git 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 --- 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);