From e4bdb92d0f575416d4ab4943af2998482b2b5d48 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Mon, 29 Apr 2024 16:23:36 +0200 Subject: [PATCH] QmlDesigner: Fix adding keyframe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Reviewed-by: Qt CI Patch Build Bot Reviewed-by: Henning Gründl --- .../HelperWidgets/ExtendedFunctionLogic.qml | 2 +- .../propertyeditor/propertyeditorvalue.cpp | 17 +++++++++++++++++ .../propertyeditor/propertyeditorvalue.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ExtendedFunctionLogic.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ExtendedFunctionLogic.qml index 76e6bd8f094..8a8c8c33ce6 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ExtendedFunctionLogic.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ExtendedFunctionLogic.qml @@ -103,7 +103,7 @@ Item { StudioControls.MenuItem { text: qsTr("Insert Keyframe") enabled: hasActiveTimeline - onTriggered: insertKeyframe(backendValue.name) + onTriggered: backendValue.insertKeyframe() } } } diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index 80ee2ea1723..412db1055fa 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -548,6 +548,23 @@ void PropertyEditorValue::setForceBound(bool b) 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 { QString copy = string; diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h index 70a51fffc2c..c4b09f6b5af 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h @@ -172,6 +172,8 @@ public: Q_INVOKABLE void setForceBound(bool b); + Q_INVOKABLE void insertKeyframe(); + public slots: void resetValue(); void setEnumeration(const QString &scope, const QString &name);