From f4f89858cffa1107af5139dfb1e1d7b16ca3a1a0 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 6 Jun 2017 14:54:37 +0200 Subject: Use GradientStop and rename ShapeLinearGradient to LinearGradient Thus application code becomes: ShapePath { ... fillGradient: LinearGradient { ... GradientStop { ... } } } which is even more clean and readable. The duplication for stops is now avoided. Change-Id: I50ae2f388e21683a37dc4787763dc71e16eef4f5 Reviewed-by: Mitch Curtis Reviewed-by: J-P Nurmi --- src/imports/shapes/qquickshape_p.h | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'src/imports/shapes/qquickshape_p.h') diff --git a/src/imports/shapes/qquickshape_p.h b/src/imports/shapes/qquickshape_p.h index a01c36e971..50b242e492 100644 --- a/src/imports/shapes/qquickshape_p.h +++ b/src/imports/shapes/qquickshape_p.h @@ -55,38 +55,16 @@ #include #include -#include -#include +#include QT_BEGIN_NAMESPACE class QQuickShapePathPrivate; class QQuickShapePrivate; -class QQuickShapeGradientStop : public QObject +class QQuickShapeGradient : public QQuickGradient { Q_OBJECT - Q_PROPERTY(qreal position READ position WRITE setPosition) - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - QQuickShapeGradientStop(QObject *parent = nullptr); - - qreal position() const; - void setPosition(qreal position); - - QColor color() const; - void setColor(const QColor &color); - -private: - qreal m_position; - QColor m_color; -}; - -class QQuickShapeGradient : public QObject -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty stops READ stops) Q_PROPERTY(SpreadMode spread READ spread WRITE setSpread NOTIFY spreadChanged) Q_CLASSINFO("DefaultProperty", "stops") @@ -100,23 +78,13 @@ public: QQuickShapeGradient(QObject *parent = nullptr); - QQmlListProperty stops(); - - QGradientStops sortedGradientStops() const; - SpreadMode spread() const; void setSpread(SpreadMode mode); signals: - void updated(); void spreadChanged(); private: - static int countStops(QQmlListProperty *list); - static QObject *atStop(QQmlListProperty *list, int index); - static void appendStop(QQmlListProperty *list, QObject *stop); - - QVector m_stops; SpreadMode m_spread; }; -- cgit v1.2.3