1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the QtGraphs API. It exists purely as an
9// implementation detail. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13
14#ifndef COLORGRADIENT_P_H
15#define COLORGRADIENT_P_H
16
17#include <private/graphsglobal_p.h>
18#include <QtGui/QColor>
19#include <QtQml/qqml.h>
20
21QT_BEGIN_NAMESPACE
22
23class ColorGradientStop : public QObject
24{
25 Q_OBJECT
26
27 Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged)
28 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
29
30 QML_ELEMENT
31
32public:
33 ColorGradientStop(QObject *parent = 0);
34
35 qreal position() const;
36 void setPosition(qreal position);
37
38 QColor color() const;
39 void setColor(const QColor &color);
40
41Q_SIGNALS:
42 void positionChanged(qreal position);
43 void colorChanged(const QColor &color);
44
45private:
46 void updateGradient();
47
48private:
49 qreal m_position;
50 QColor m_color;
51};
52
53class ColorGradient : public QObject
54{
55 Q_OBJECT
56
57 Q_PROPERTY(QQmlListProperty<ColorGradientStop> stops READ stops CONSTANT)
58 Q_CLASSINFO("DefaultProperty", "stops")
59
60 QML_ELEMENT
61
62public:
63 ColorGradient(QObject *parent = 0);
64 ~ColorGradient();
65
66 QQmlListProperty<ColorGradientStop> stops();
67
68 void doUpdate();
69 QList<ColorGradientStop *> m_stops;
70
71Q_SIGNALS:
72 void updated();
73};
74
75QT_END_NAMESPACE
76
77#endif
78

source code of qtgraphs/src/graphs/qml/colorgradient_p.h