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 <mahmoud.badri@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Miikka Heikkinen
2022-10-18 12:35:55 +03:00
parent 2d5512f2c4
commit c45f4eb654
2 changed files with 19 additions and 7 deletions

View File

@@ -159,9 +159,11 @@ EasingCurveDialog::EasingCurveDialog(const QList<ModelNode> &frames, QWidget *pa
resize(QSize(1421, 918)); resize(QSize(1421, 918));
} }
void EasingCurveDialog::initialize(const QString &curveString) void EasingCurveDialog::initialize(const PropertyName &propName, const QString &curveString)
{ {
EasingCurve curve; EasingCurve curve;
m_easingCurveProperty = propName;
if (curveString.isEmpty()) { if (curveString.isEmpty()) {
QEasingCurve qcurve; QEasingCurve qcurve;
qcurve.addCubicBezierSegment(QPointF(0.2, 0.2), QPointF(0.8, 0.8), QPointF(1.0, 1.0)); 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<ModelNode> &frames, QWidget *paren
EasingCurveDialog dialog(frames, parent); EasingCurveDialog dialog(frames, parent);
ModelNode current = frames.last(); ModelNode current = frames.last();
PropertyName propName;
if (current.hasBindingProperty("easing.bezierCurve")) NodeMetaInfo metaInfo = current.metaInfo();
dialog.initialize(current.bindingProperty("easing.bezierCurve").expression()); if (metaInfo.hasProperty("easing"))
else propName = "easing.bezierCurve";
dialog.initialize(""); 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(); dialog.exec();
} }
@@ -207,7 +217,7 @@ bool EasingCurveDialog::apply()
return view->executeInTransaction("EasingCurveDialog::apply", [this](){ return view->executeInTransaction("EasingCurveDialog::apply", [this](){
auto expression = m_splineEditor->easingCurve().toString(); auto expression = m_splineEditor->easingCurve().toString();
for (const auto &frame : qAsConst(m_frames)) for (const auto &frame : qAsConst(m_frames))
frame.bindingProperty("easing.bezierCurve").setExpression(expression); frame.bindingProperty(m_easingCurveProperty).setExpression(expression);
}); });
} }

View File

@@ -49,7 +49,7 @@ class EasingCurveDialog : public QDialog
public: public:
EasingCurveDialog(const QList<ModelNode> &frames, QWidget *parent = nullptr); EasingCurveDialog(const QList<ModelNode> &frames, QWidget *parent = nullptr);
void initialize(const QString &curveString); void initialize(const PropertyName &propName, const QString &curveString);
static void runDialog(const QList<ModelNode> &frames, QWidget *parent = nullptr); static void runDialog(const QList<ModelNode> &frames, QWidget *parent = nullptr);
@@ -80,6 +80,8 @@ private:
QLabel *m_label = nullptr; QLabel *m_label = nullptr;
QList<ModelNode> m_frames; QList<ModelNode> m_frames;
PropertyName m_easingCurveProperty;
}; };
} // namespace QmlDesigner } // namespace QmlDesigner