diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2023-12-05 13:58:57 +0100 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2023-12-07 14:40:55 +0000 |
commit | c3d22dfcd986af9ce4ff94c94518e278c8029bb4 (patch) | |
tree | 549990581fb6fe563b47934282b0922aa4aabb35 | |
parent | b5370c435eabc647e30e5dd366d668b65a076a04 (diff) |
QmlDesigner: Avoid deletion and recreation of keyframes if possible
Without this all keyframes are first deleted and then recreated.
This becomes notable slow with a larger number of keyframes, since the
timeline does react to each deletion/creation and rebuilds the scene
for the group.
Instead we can keep all keyframes and simply adjust their frame.
Change-Id: Ic34ffbdea74f57cf8f5bcddfbce8a8c18ffef7b0
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp b/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp index e7395c6662..afe704a59d 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp @@ -307,10 +307,20 @@ void CurveEditorView::commitKeyframes(TreeItem *item) auto replaceKeyframes = [&group, pitem, this]() mutable { m_block = true; - for (auto& frame : group.keyframes()) - frame.destroy(); - AnimationCurve curve = pitem->curve(); + + unsigned int i = 0; + const size_t numberOfKeyFrames = curve.keyframes().size(); + for (auto &frame : group.keyframes()) { + if (i < numberOfKeyFrames) { + QPointF pos = curve.keyframes().at(i).position(); + frame.variantProperty("frame").setValue(pos.x()); + } else { + frame.destroy(); + } + i++; + } + if (curve.valueType() == AnimationCurve::ValueType::Bool) { for (const auto& frame : curve.keyframes()) { QPointF pos = frame.position(); |