QmlDesigner: Add insertKeyframe to QmlTimeline

Change-Id: I405cab4ece5420098ee9d5b3ce823d2b4c1d9339
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2021-04-20 16:18:21 +02:00
parent 2da6b66210
commit 1077ceefd8
2 changed files with 15 additions and 0 deletions

View File

@@ -74,6 +74,8 @@ public:
bool hasKeyframeGroup(const ModelNode &node, const PropertyName &propertyName) const;
bool hasKeyframeGroupForTarget(const ModelNode &node) const;
void insertKeyframe(const ModelNode &target, const PropertyName &propertyName);
private:
void addKeyframeGroupIfNotExists(const ModelNode &node, const PropertyName &propertyName);
QList<QmlTimelineKeyframeGroup> allKeyframeGroups() const;

View File

@@ -294,6 +294,19 @@ bool QmlTimeline::hasKeyframeGroupForTarget(const ModelNode &node) const
return false;
}
void QmlTimeline::insertKeyframe(const ModelNode &target, const PropertyName &propertyName)
{
ModelNode targetNode = target;
QmlTimelineKeyframeGroup timelineFrames(keyframeGroup(targetNode, propertyName));
QTC_ASSERT(timelineFrames.isValid(), return );
const qreal frame = modelNode().auxiliaryData("currentFrame@NodeInstance").toReal();
const QVariant value = QmlObjectNode(targetNode).instanceValue(propertyName);
timelineFrames.setValue(value, frame);
}
QList<QmlTimelineKeyframeGroup> QmlTimeline::allKeyframeGroups() const
{
QList<QmlTimelineKeyframeGroup> returnList;