diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2019-05-22 10:23:34 +0200 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2019-05-22 11:04:28 +0000 |
commit | fd24586421d837ec16fb4511ce5f1fe299734d12 (patch) | |
tree | 54a1b905a35b34bb6d8bc534346dc52a18d2c3a2 | |
parent | 8aa227a7783b990e8dc4a5c9610eee4e8858a275 (diff) |
QmlDesigner: Properly reset line edits if an error occurs
Task-number: QDS-707
Change-Id: Ic70c4296afd8bd6b590242fea129624af2fee7a6
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r-- | src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.cpp | 11 | ||||
-rw-r--r-- | src/plugins/qmldesigner/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"); |