forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user