diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp index f9eb7465e22..9cf92f14405 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp @@ -24,11 +24,13 @@ ****************************************************************************/ #include "propertyeditorcontextobject.h" +#include "timelineeditor/easingcurvedialog.h" #include #include #include #include +#include #include #include @@ -39,6 +41,8 @@ #include #include +#include + static uchar fromHex(const uchar c, const uchar c2) { uchar rv = 0; @@ -406,4 +410,38 @@ void PropertyEditorContextObject::restoreCursor() QApplication::restoreOverrideCursor(); } +void EasingCurveEditor::registerDeclarativeType() +{ + qmlRegisterType("HelperWidgets", 2, 0, "EasingCurveEditor"); +} + +void EasingCurveEditor::runDialog() +{ + if (m_modelNode.isValid()) + EasingCurveDialog::runDialog({ m_modelNode }, Core::ICore::dialogParent()); +} + +void EasingCurveEditor::setModelNodeBackend(const QVariant &modelNodeBackend) +{ + if (!modelNodeBackend.isNull() && modelNodeBackend.isValid()) { + m_modelNodeBackend = modelNodeBackend; + + const auto modelNodeBackendObject = m_modelNodeBackend.value(); + + const auto backendObjectCasted = + qobject_cast(modelNodeBackendObject); + + if (backendObjectCasted) { + m_modelNode = backendObjectCasted->qmlObjectNode().modelNode(); + } + + emit modelNodeBackendChanged(); + } +} + +QVariant EasingCurveEditor::modelNodeBackend() const +{ + return m_modelNodeBackend; +} + } //QmlDesigner diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h index 150800febae..c38531ce8b9 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h @@ -26,6 +26,7 @@ #pragma once #include +#include #include #include @@ -170,4 +171,30 @@ private: bool m_setHasActiveTimeline = false; }; +class EasingCurveEditor : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend NOTIFY modelNodeBackendChanged) + +public: + EasingCurveEditor(QObject *parent = nullptr) : QObject(parent) + {} + + static void registerDeclarativeType(); + Q_INVOKABLE void runDialog(); + void setModelNodeBackend(const QVariant &modelNodeBackend); + +signals: + void modelNodeBackendChanged(); + +private: + QVariant modelNodeBackend() const; + +private: + QVariant m_modelNodeBackend; + QmlDesigner::ModelNode m_modelNode; +}; + + } //QmlDesigner { diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp index 7f705e43c6a..e8c85bc1b6c 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp @@ -38,6 +38,7 @@ #include "qmlanchorbindingproxy.h" #include "theme.h" #include "aligndistribute.h" +#include "propertyeditorcontextobject.h" #include "tooltip.h" namespace QmlDesigner { @@ -67,6 +68,7 @@ void Quick2PropertyEditorView::registerQmlTypes() AnnotationEditor::registerDeclarativeType(); AlignDistribute::registerDeclarativeType(); Tooltip::registerDeclarativeType(); + EasingCurveEditor::registerDeclarativeType(); } }