1 | /* |
2 | * This file is part of KQuickCharts |
3 | * SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org> |
4 | * SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org> |
5 | * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> |
6 | * |
7 | * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
8 | */ |
9 | |
10 | #ifndef COLORGRADIENTSOURCE_H |
11 | #define COLORGRADIENTSOURCE_H |
12 | |
13 | #include <QColor> |
14 | #include <QList> |
15 | |
16 | #include "ChartDataSource.h" |
17 | |
18 | /*! |
19 | * \qmltype ColorGradientSource |
20 | * \inherits ChartDataSource |
21 | * \inqmlmodule org.kde.quickcharts |
22 | * |
23 | * \brief A data source that provides a hue-shifted color as data. |
24 | */ |
25 | class QUICKCHARTS_EXPORT ColorGradientSource : public ChartDataSource |
26 | { |
27 | Q_OBJECT |
28 | QML_ELEMENT |
29 | |
30 | public: |
31 | explicit ColorGradientSource(QObject *parent = nullptr); |
32 | |
33 | /*! |
34 | * \qmlproperty color ColorGradientSource::baseColor |
35 | */ |
36 | Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor NOTIFY baseColorChanged) |
37 | QColor baseColor() const; |
38 | void setBaseColor(const QColor &newBaseColor); |
39 | Q_SIGNAL void baseColorChanged(); |
40 | |
41 | /*! |
42 | * \qmlproperty int ColorGradientSource::itemCount |
43 | */ |
44 | Q_PROPERTY(int itemCount READ itemCount WRITE setItemCount NOTIFY itemCountChanged) |
45 | void setItemCount(int newItemCount); |
46 | Q_SIGNAL void itemCountChanged(); |
47 | |
48 | /*! |
49 | * \qmlproperty list<variant> ColorGradientSource::colors |
50 | */ |
51 | Q_PROPERTY(QVariantList colors READ colors NOTIFY dataChanged) |
52 | QVariantList colors() const; |
53 | |
54 | int itemCount() const override; |
55 | QVariant item(int index) const override; |
56 | QVariant minimum() const override; |
57 | QVariant maximum() const override; |
58 | |
59 | private: |
60 | void regenerateColors(); |
61 | |
62 | QColor m_baseColor = Qt::blue; |
63 | int m_itemCount = 0; |
64 | QList<QColor> m_colors; |
65 | }; |
66 | |
67 | #endif // COLORGRADIENTSOURCE_H |
68 | |