KQuickCharts

ColorGradientSource.h
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 * A data source that provides a hue-shifted color as data.
20 */
21class QUICKCHARTS_EXPORT ColorGradientSource : public ChartDataSource
22{
23 Q_OBJECT
24 QML_ELEMENT
25
26public:
27 explicit ColorGradientSource(QObject *parent = nullptr);
28
29 Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor NOTIFY baseColorChanged)
30 QColor baseColor() const;
31 void setBaseColor(const QColor &newBaseColor);
32 Q_SIGNAL void baseColorChanged();
33
34 Q_PROPERTY(int itemCount READ itemCount WRITE setItemCount NOTIFY itemCountChanged)
35 void setItemCount(int newItemCount);
36 Q_SIGNAL void itemCountChanged();
37
38 Q_PROPERTY(QVariantList colors READ colors NOTIFY dataChanged)
39 QVariantList colors() const;
40
41 int itemCount() const override;
42 QVariant item(int index) const override;
43 QVariant minimum() const override;
44 QVariant maximum() const override;
45
46private:
47 void regenerateColors();
48
49 QColor m_baseColor = Qt::blue;
50 int m_itemCount = 0;
51 QList<QColor> m_colors;
52};
53
54#endif // COLORGRADIENTSOURCE_H
Abstract base class for data sources.
A data source that provides a hue-shifted color as data.
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.