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);