From fd24586421d837ec16fb4511ce5f1fe299734d12 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 22 May 2019 10:23:34 +0200 Subject: QmlDesigner: Properly reset line edits if an error occurs Task-number: QDS-707 Change-Id: Ic70c4296afd8bd6b590242fea129624af2fee7a6 Reviewed-by: Tim Jenssen --- .../timelineeditor/timelineanimationform.cpp | 11 ++++++++++- .../qmldesignerextension/timelineeditor/timelineform.cpp | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.cpp index 4fc04b5759..65f77a0e5f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.cpp +++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.cpp @@ -85,14 +85,23 @@ TimelineAnimationForm::TimelineAnimationForm(QWidget *parent) if (newId == animation().id()) return; - if (!animation().isValidId(newId)) { + bool error = false; + + if (!ModelNode::isValidId(newId)) { Core::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 is an invalid id.").arg(newId)); + error = true; } else if (animation().view()->hasId(newId)) { Core::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 already exists.").arg(newId)); } else { animation().setIdWithRefactoring(newId); + error = true; + } + + if (error) { + lastString.clear(); + ui->idLineEdit->setText(animation().id()); } }); diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.cpp index 3c1c3950dd..eb63ad4883 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.cpp +++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.cpp @@ -98,15 +98,24 @@ TimelineForm::TimelineForm(QWidget *parent) if (newId == m_timeline.modelNode().id()) return; - if (!m_timeline.modelNode().isValidId(newId)) { + bool error = false; + + if (!ModelNode::isValidId(newId)) { Core::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 is an invalid id.").arg(newId)); + error = true; } else if (m_timeline.view()->hasId(newId)) { Core::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 already exists.").arg(newId)); + error = true; } else { m_timeline.modelNode().setIdWithRefactoring(newId); } + + if (error) { + lastString.clear(); + ui->idLineEdit->setText(m_timeline.modelNode().id()); + } }); connectSpinBox(ui->startFrame, "startFrame"); -- cgit v1.2.3