From 1ba7c149af2fc0219de81089ab75bce29e1e255b Mon Sep 17 00:00:00 2001 From: Knud Dollereder Date: Tue, 2 Mar 2021 12:26:40 +0100 Subject: [PATCH] Enable step functions in the curve-editor ... and shut-up an annoying qDebug log in the transition-editor. Change-Id: Iea8b48e48bb7e52cd4c845f28c49f8a513785fab Reviewed-by: Thomas Hartmann --- .../qmldesigner/components/curveeditor/curveeditor.cpp | 4 +++- .../qmldesigner/components/curveeditor/curveeditorview.cpp | 5 ++--- .../qmldesigner/components/curveeditor/curvesegment.cpp | 7 +++++++ .../components/transitioneditor/transitioneditorview.cpp | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditor.cpp b/src/plugins/qmldesigner/components/curveeditor/curveeditor.cpp index 800dc0c523b..23623ae3095 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditor.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditor.cpp @@ -100,7 +100,9 @@ QToolBar *CurveEditor::createToolBar(CurveEditorModel *model) auto setLinearInterpolation = [this]() { m_view->setInterpolation(Keyframe::Interpolation::Linear); }; - auto setStepInterpolation = [this]() { m_view->setInterpolation(Keyframe::Interpolation::Step); }; + auto setStepInterpolation = [this]() { + m_view->setInterpolation(Keyframe::Interpolation::Step); + }; auto setSplineInterpolation = [this]() { m_view->setInterpolation(Keyframe::Interpolation::Bezier); }; diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp b/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp index 51fc7c31a32..b885b3d91c5 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditorview.cpp @@ -338,7 +338,8 @@ void CurveEditorView::commitKeyframes(TreeItem *item) group.setValue(QVariant(pos.y()), pos.x()); if (previous.isValid()) { - if (frame.interpolation() == Keyframe::Interpolation::Bezier) { + if (frame.interpolation() == Keyframe::Interpolation::Bezier || + frame.interpolation() == Keyframe::Interpolation::Step ) { CurveSegment segment(previous, frame); if (segment.isValid()) attachEasingCurve(group, pos.x(), segment.easingCurve()); @@ -346,8 +347,6 @@ void CurveEditorView::commitKeyframes(TreeItem *item) QVariant data = frame.data(); if (data.type() == static_cast(QMetaType::QEasingCurve)) attachEasingCurve(group, pos.x(), data.value()); - } else if (frame.interpolation() == Keyframe::Interpolation::Step) { - // Warning: Keyframe::Interpolation::Step not yet implemented } } diff --git a/src/plugins/qmldesigner/components/curveeditor/curvesegment.cpp b/src/plugins/qmldesigner/components/curveeditor/curvesegment.cpp index 75d956c666c..cf2861991bd 100644 --- a/src/plugins/qmldesigner/components/curveeditor/curvesegment.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/curvesegment.cpp @@ -294,6 +294,13 @@ void CurveSegment::extend(QPainterPath &path) const QEasingCurve CurveSegment::easingCurve() const { + if (interpolation() == Keyframe::Interpolation::Step) { + QEasingCurve curve; + curve.addCubicBezierSegment(QPointF(0.1, 0.0), QPointF(0.9, 0.0), QPointF(1.0, 0.0)); + curve.addCubicBezierSegment(QPointF(1.0, 0.1), QPointF(1.0, 0.9), QPointF(1.0, 1.0)); + return curve; + } + auto mapPosition = [this](const QPointF &position) { QPointF min = m_left.position(); QPointF max = m_right.position(); diff --git a/src/plugins/qmldesigner/components/transitioneditor/transitioneditorview.cpp b/src/plugins/qmldesigner/components/transitioneditor/transitioneditorview.cpp index 3b648f5435a..97dc457f39c 100644 --- a/src/plugins/qmldesigner/components/transitioneditor/transitioneditorview.cpp +++ b/src/plugins/qmldesigner/components/transitioneditor/transitioneditorview.cpp @@ -110,7 +110,7 @@ void TransitionEditorView::nodeReparented(const ModelNode &node, const ModelNode parent = newPropertyParent.parentModelNode(); - qDebug() << Q_FUNC_INFO << parent; + // qDebug() << Q_FUNC_INFO << parent; if (parent.isValid() && parent.metaInfo().isValid() && parent.metaInfo().isSubclassOf("QtQuick.Transition")) { asyncUpdate(parent);