Ignore Enter key in formula field.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-29 20:00:38 +02:00
parent 8158261dcc
commit 8a10d43778
15 changed files with 40 additions and 0 deletions

View File

@ -52,6 +52,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -57,6 +57,10 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par
this->formulaBaseHeightF1 = ui->plainTextEditF1->height();
this->formulaBaseHeightF2 = ui->plainTextEditF2->height();
ui->plainTextEditFormula->installEventFilter(this);
ui->plainTextEditF1->installEventFilter(this);
ui->plainTextEditF2->installEventFilter(this);
timerRadius = new QTimer(this);
connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius);

View File

@ -52,6 +52,7 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -48,6 +48,7 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -51,6 +51,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -50,6 +50,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -50,6 +50,7 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -38,6 +38,7 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
InitVariables(ui);
InitFormulaUI(ui);
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancel(ui);
flagFormula = false;

View File

@ -55,6 +55,9 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
this->formulaBaseHeight = ui->plainTextEditFormula->height();
this->formulaBaseHeightAngle = ui->plainTextEditAngle->height();
ui->plainTextEditFormula->installEventFilter(this);
ui->plainTextEditAngle->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
CheckState();

View File

@ -48,6 +48,7 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -48,6 +48,7 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -50,6 +50,7 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -52,6 +52,7 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;

View File

@ -401,6 +401,27 @@ void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit)
plainTextEdit->setTextCursor(cursor);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogTool::eventFilter(QObject *object, QEvent *event)
{
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object);
if (plainTextEdit != nullptr)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if ((keyEvent->key() == Qt::Key_Enter) || (keyEvent->key() == Qt::Key_Return))
{
// Ignore Enter key
return true;
}
}
else
{
// pass the event on to the parent class
return QDialog::eventFilter(object, event);
}
return false;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ValFormulaChanged handle change formula

View File

@ -334,6 +334,7 @@ protected:
*/
virtual void SaveData(){}
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit);
bool eventFilter(QObject *object, QEvent *event);
private:
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
};