-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <ModuleBase_WidgetEditor.h>
#include <GeomDataAPI_Point2D.h>
#include <QApplication>
+#include <QKeyEvent>
#include <QLineEdit>
#include <QMenu>
#include <QWidget>
#include <QDialog>
#include <QLayout>
+// Dialog is redefined to avoid Escape key processing
+class ModuleBase_EditorDialog : public QDialog
+{
+public:
+ ModuleBase_EditorDialog(QWidget* theParent, Qt::WindowFlags theFlags)
+ : QDialog(theParent, theFlags)
+ {
+ setMinimumWidth(100);
+ }
+ ~ModuleBase_EditorDialog() {}
+
+protected:
+ // Do nothing if key pressed because it is processing on operation manager level
+ virtual void keyPressEvent(QKeyEvent* theEvent) {
+ if (theEvent->key() == Qt::Key_Escape)
+ return;
+ QDialog::keyPressEvent(theEvent);
+ }
+};
+
ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
const Config_WidgetAPI* theData)
: ModuleBase_WidgetDoubleValue(theParent, theData),
{
bool isValueAccepted = false;
- myEditorDialog = new QDialog(QApplication::desktop(), Qt::FramelessWindowHint);
+ myEditorDialog = new ModuleBase_EditorDialog(QApplication::desktop(), Qt::FramelessWindowHint);
QHBoxLayout* aLay = new QHBoxLayout(myEditorDialog);
aLay->setContentsMargins(2, 2, 2, 2);
ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(myEditorDialog);
anEditor->setMinimum(theSpinMinValue);
anEditor->setMaximum(theSpinMaxValue);
+
+ QStringList aParameters;
+ ModuleBase_Tools::getParameters(aParameters);
+ anEditor->setCompletionList(aParameters);
+
if (outText.isEmpty())
anEditor->setValue(outValue);
else
}
ModuleBase_Tools::setFocus(mySpinBox, "ModuleBase_WidgetEditor::editedValue");
mySpinBox->selectAll();
-
- if (theSendSignals && !myIsEditing)
- emit enterClicked(this);
+ // enter is processed, so we need not anymore emit clicked signal
+ //if (theSendSignals && !myIsEditing && isValueAccepted)
+ // emit enterClicked(this);
return isValueAccepted;
}
return ModuleBase_WidgetDoubleValue::processEnter();
}
+
+bool ModuleBase_WidgetEditor::processEscape()
+{
+ if (myEditorDialog) {
+ myEditorDialog->reject();
+ return true;
+ }
+
+ return ModuleBase_WidgetDoubleValue::processEscape();
+}