QmlDesigner: Fix adding keyframe

Keyframes were always added on the selected model node
instead of the modelnode belonging to the property.

Task-number: QDS-12622
Change-Id: Iae44cfecd862d79b14c062854d5f329da595f729
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Thomas Hartmann
2024-04-29 16:23:36 +02:00
parent c1172ced98
commit e4bdb92d0f
3 changed files with 20 additions and 1 deletions

View File

@@ -103,7 +103,7 @@ Item {
StudioControls.MenuItem { StudioControls.MenuItem {
text: qsTr("Insert Keyframe") text: qsTr("Insert Keyframe")
enabled: hasActiveTimeline enabled: hasActiveTimeline
onTriggered: insertKeyframe(backendValue.name) onTriggered: backendValue.insertKeyframe()
} }
} }
} }

View File

@@ -548,6 +548,23 @@ void PropertyEditorValue::setForceBound(bool b)
emit isBoundChanged(); emit isBoundChanged();
} }
void PropertyEditorValue::insertKeyframe()
{
if (!m_modelNode.isValid())
return;
/*If we add more code here we have to forward the property editor view */
AbstractView *view = m_modelNode.view();
QmlTimeline timeline = view->currentTimeline();
QTC_ASSERT(timeline.isValid(), return );
QTC_ASSERT(m_modelNode.isValid(), return );
view->executeInTransaction("PropertyEditorContextObject::insertKeyframe",
[&] { timeline.insertKeyframe(m_modelNode, name()); });
}
QStringList PropertyEditorValue::generateStringList(const QString &string) const QStringList PropertyEditorValue::generateStringList(const QString &string) const
{ {
QString copy = string; QString copy = string;

View File

@@ -172,6 +172,8 @@ public:
Q_INVOKABLE void setForceBound(bool b); Q_INVOKABLE void setForceBound(bool b);
Q_INVOKABLE void insertKeyframe();
public slots: public slots:
void resetValue(); void resetValue();
void setEnumeration(const QString &scope, const QString &name); void setEnumeration(const QString &scope, const QString &name);