From c45f4eb654fd2a71c377f551bf8e5a55da54e2dc Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 18 Oct 2022 12:35:55 +0300 Subject: [PATCH] QmlDesigner: Add support for easingCurve property to EasingCurveDialog QtQuick3D.Particles3D.ScaleAffector has easingCurve property. We want to use existing EasingCurveDialog to edit the value, but the current dialog only supports property named 'easing' (used in animations). Added support for 'easingCurve' property as well. Task-number: QDS-8014 Change-Id: If0f47608f7ed3cb9db4a44f632d15b2135856800 Reviewed-by: Mahmoud Badri Reviewed-by: Qt CI Bot Reviewed-by: Thomas Hartmann --- .../timelineeditor/easingcurvedialog.cpp | 22 ++++++++++++++----- .../timelineeditor/easingcurvedialog.h | 4 +++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp index 99e97d72de8..79f8141bf0b 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp @@ -159,9 +159,11 @@ EasingCurveDialog::EasingCurveDialog(const QList &frames, QWidget *pa resize(QSize(1421, 918)); } -void EasingCurveDialog::initialize(const QString &curveString) +void EasingCurveDialog::initialize(const PropertyName &propName, const QString &curveString) { EasingCurve curve; + m_easingCurveProperty = propName; + if (curveString.isEmpty()) { QEasingCurve qcurve; qcurve.addCubicBezierSegment(QPointF(0.2, 0.2), QPointF(0.8, 0.8), QPointF(1.0, 1.0)); @@ -180,11 +182,19 @@ void EasingCurveDialog::runDialog(const QList &frames, QWidget *paren EasingCurveDialog dialog(frames, parent); ModelNode current = frames.last(); + PropertyName propName; - if (current.hasBindingProperty("easing.bezierCurve")) - dialog.initialize(current.bindingProperty("easing.bezierCurve").expression()); - else - dialog.initialize(""); + NodeMetaInfo metaInfo = current.metaInfo(); + if (metaInfo.hasProperty("easing")) + propName = "easing.bezierCurve"; + else if (metaInfo.hasProperty("easingCurve")) + propName = "easingCurve.bezierCurve"; + + QString expression; + if (!propName.isEmpty() && current.hasBindingProperty(propName)) + expression = current.bindingProperty(propName).expression(); + + dialog.initialize(propName, expression); dialog.exec(); } @@ -207,7 +217,7 @@ bool EasingCurveDialog::apply() return view->executeInTransaction("EasingCurveDialog::apply", [this](){ auto expression = m_splineEditor->easingCurve().toString(); for (const auto &frame : qAsConst(m_frames)) - frame.bindingProperty("easing.bezierCurve").setExpression(expression); + frame.bindingProperty(m_easingCurveProperty).setExpression(expression); }); } diff --git a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h index a8c026989c2..3f6ea95a5e0 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h @@ -49,7 +49,7 @@ class EasingCurveDialog : public QDialog public: EasingCurveDialog(const QList &frames, QWidget *parent = nullptr); - void initialize(const QString &curveString); + void initialize(const PropertyName &propName, const QString &curveString); static void runDialog(const QList &frames, QWidget *parent = nullptr); @@ -80,6 +80,8 @@ private: QLabel *m_label = nullptr; QList m_frames; + + PropertyName m_easingCurveProperty; }; } // namespace QmlDesigner