forked from bitcoin-core/gui-qml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinegraph.h
More file actions
67 lines (58 loc) · 2.68 KB
/
Copy pathlinegraph.h
File metadata and controls
67 lines (58 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2023 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QML_CONTROLS_LINEGRAPH_H
#define BITCOIN_QML_CONTROLS_LINEGRAPH_H
#include <QLinearGradient>
#include <QPainter>
#include <QPainterPath>
#include <QQueue>
#include <QQuickPaintedItem>
class LineGraph : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
Q_PROPERTY(QColor gradientColor READ gradientColor WRITE setGradientColor)
Q_PROPERTY(QColor lineColor READ lineColor WRITE setLineColor)
Q_PROPERTY(QColor markerLineColor READ markerLineColor WRITE setMarkerLineColor)
Q_PROPERTY(int maxSamples READ maxSamples WRITE setMaxSamples)
Q_PROPERTY(float maxValue READ maxValue WRITE setMaxValue)
Q_PROPERTY(QQueue<float> valueList READ valueList WRITE setValueList)
public:
explicit LineGraph(QQuickItem * parent = nullptr);
void paint(QPainter * painter) override;
QColor backgroundColor() const { return m_background_color; };
QColor borderColor() const { return m_border_color; };
QColor gradientColor() const { return m_gradient_color; };
QColor lineColor() const { return m_line_color; };
QColor markerLineColor() const { return m_marker_line_color; };
int maxSamples() const { return m_max_samples; };
float maxValue() const { return m_max_value; };
QQueue<float> valueList() const { return m_value_list; };
public Q_SLOTS:
void setBackgroundColor(QColor color);
void setBorderColor(QColor color);
void setGradientColor(QColor color);
void setLineColor(QColor color);
void setMarkerLineColor(QColor color);
void setMaxSamples(int max_samples);
void setMaxValue(float max_value);
void setValueList(QQueue<float> value_list);
private:
void paintGraphBorder(QPainter * painter);
void paintMarkerLines(QPainter * painter);
void paintPath(QPainterPath * painter_path);
void paintTraffic(QPainter * painter);
void setupGradient(QPainterPath * painter);
QColor m_background_color{"#2D2D2D"};
QColor m_border_color{"#000000"};
QColor m_gradient_color{"#000000"};
QLinearGradient m_fill_gradient{0, 0, 0, 0};
QColor m_line_color{"#000000"};
QColor m_marker_line_color{"#000000"};
int m_max_samples{0};
float m_max_value{0};
QQueue<float> m_value_list;
};
#endif // BITCOIN_QML_CONTROLS_LINEGRAPH_H