-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdashboardwidget.h
92 lines (69 loc) · 2.99 KB
/
dashboardwidget.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef DASHBOARDWIDGET_H
#define DASHBOARDWIDGET_H
#include <QWidget>
class DashBoardWidget : public QWidget
{
Q_OBJECT
Q_PROPERTY(double value READ value WRITE setValue)
Q_PROPERTY(double min READ min WRITE setMin)
Q_PROPERTY(double max READ max WRITE setmax)
Q_PROPERTY(double startAngle READ startAngle WRITE setStartAngle)
Q_PROPERTY(double endAngle READ endAngle WRITE setEndAngle)
Q_PROPERTY(int scaleMajor READ scaleMajor WRITE setScaleMajor)
Q_PROPERTY(int scaleMinor READ scaleMinor WRITE setScaleMinor)
Q_PROPERTY(QString unit READ unit WRITE setUnit)
Q_PROPERTY(QString text READ text WRITE setText)
Q_PROPERTY(QColor arcColor READ arcColor WRITE setArcColor)
Q_PROPERTY(QColor scaleColor READ scaleColor WRITE setScaleColor)
Q_PROPERTY(QColor pointerColor READ pointerColor WRITE setPointerColor)
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
public:
explicit DashBoardWidget(QWidget *parent = nullptr);
~DashBoardWidget() override;
[[nodiscard]] auto sizeHint() const -> QSize override;
[[nodiscard]] auto minimumSizeHint() const -> QSize override;
[[nodiscard]] auto value() const -> double;
void setValue(const double value);
void setMin(const double min);
[[nodiscard]] auto min() const -> double;
void setmax(const double max);
[[nodiscard]] auto max() const -> double;
void setStartAngle(const double startAngle);
[[nodiscard]] auto startAngle() const -> double;
void setEndAngle(const double endAngle);
[[nodiscard]] auto endAngle() const -> double;
void setScaleMajor(const int scale);
[[nodiscard]] auto scaleMajor() const -> int;
void setScaleMinor(const int scale);
[[nodiscard]] auto scaleMinor() const -> int;
void setUnit(const QString &unit);
[[nodiscard]] auto unit() const -> QString;
void setText(const QString &text);
[[nodiscard]] auto text() const -> QString;
void setArcColor(const QColor &color);
[[nodiscard]] auto arcColor() const -> QColor;
void setScaleColor(const QColor &color);
[[nodiscard]] auto scaleColor() const -> QColor;
void setPointerColor(const QColor &color);
[[nodiscard]] auto pointerColor() const -> QColor;
void setTextColor(const QColor &color);
[[nodiscard]] auto textColor() const -> QColor;
void setBackgroundColor(const QColor &color);
[[nodiscard]] auto backgroundColor() const -> QColor;
signals:
void valueChanged(const double value);
private slots:
void onStartAnimation(const double value);
protected:
void paintEvent(QPaintEvent *event) override;
private:
void drawArc(QPainter *painter);
void drawScale(QPainter *painter);
void drawScaleNum(QPainter *painter);
void drawPointer(QPainter *painter);
void drawValue(QPainter *painter);
struct DashBoardWidgetPrivate;
QScopedPointer<DashBoardWidgetPrivate> d_ptr;
};
#endif // DASHBOARDWIDGET_H