-
Notifications
You must be signed in to change notification settings - Fork 6
/
radialbar.h
108 lines (98 loc) · 4.04 KB
/
radialbar.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef RADIALBAR_H
#define RADIALBAR_H
#include <QQuickPaintedItem>
class RadialBar : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(qreal size READ getSize WRITE setSize NOTIFY sizeChanged)
Q_PROPERTY(qreal startAngle READ getStartAngle WRITE setStartAngle NOTIFY startAngleChanged)
Q_PROPERTY(qreal spanAngle READ getSpanAngle WRITE setSpanAngle NOTIFY spanAngleChanged)
Q_PROPERTY(qreal minValue READ getMinValue WRITE setMinValue NOTIFY minValueChanged)
Q_PROPERTY(qreal maxValue READ getMaxValue WRITE setMaxValue NOTIFY maxValueChanged)
Q_PROPERTY(qreal value READ getValue WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(int dialWidth READ getDialWidth WRITE setDialWidth NOTIFY dialWidthChanged)
Q_PROPERTY(QColor backgroundColor READ getBackgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
Q_PROPERTY(QColor foregroundColor READ getForegroundColor WRITE setForegroundColor NOTIFY foregroundColorChanged)
Q_PROPERTY(QColor progressColor READ getProgressColor WRITE setProgressColor NOTIFY progressColorChanged)
Q_PROPERTY(QColor textColor READ getTextColor WRITE setTextColor NOTIFY textColorChanged)
Q_PROPERTY(QString suffixText READ getSuffixText WRITE setSuffixText NOTIFY suffixTextChanged)
Q_PROPERTY(bool showText READ isShowText WRITE setShowText)
Q_PROPERTY(Qt::PenCapStyle penStyle READ getPenStyle WRITE setPenStyle NOTIFY penStyleChanged)
Q_PROPERTY(DialType dialType READ getDialType WRITE setDialType NOTIFY dialTypeChanged)
Q_PROPERTY(QFont textFont READ getTextFont WRITE setTextFont NOTIFY textFontChanged)
public:
RadialBar(QQuickItem *parent = 0);
void paint(QPainter *painter);
enum DialType {
FullDial,
MinToMax,
NoDial
};
Q_ENUM(DialType)
qreal getSize() {return m_Size;}
qreal getStartAngle() {return m_StartAngle;}
qreal getSpanAngle() {return m_SpanAngle;}
qreal getMinValue() {return m_MinValue;}
qreal getMaxValue() {return m_MaxValue;}
qreal getValue() {return m_Value;}
int getDialWidth() {return m_DialWidth;}
QColor getBackgroundColor() {return m_BackgroundColor;}
QColor getForegroundColor() {return m_DialColor;}
QColor getProgressColor() {return m_ProgressColor;}
QColor getTextColor() {return m_TextColor;}
QString getSuffixText() {return m_SuffixText;}
bool isShowText() {return m_ShowText;}
Qt::PenCapStyle getPenStyle() {return m_PenStyle;}
DialType getDialType() {return m_DialType;}
QFont getTextFont() {return m_TextFont;}
void setSize(qreal size);
void setStartAngle(qreal angle);
void setSpanAngle(qreal angle);
void setMinValue(qreal value);
void setMaxValue(qreal value);
void setValue(qreal value);
void setDialWidth(qreal width);
void setBackgroundColor(QColor color);
void setForegroundColor(QColor color);
void setProgressColor(QColor color);
void setTextColor(QColor color);
void setSuffixText(QString text);
void setShowText(bool show);
void setPenStyle(Qt::PenCapStyle style);
void setDialType(DialType type);
void setTextFont(QFont font);
signals:
void sizeChanged();
void startAngleChanged();
void spanAngleChanged();
void minValueChanged();
void maxValueChanged();
void valueChanged();
void dialWidthChanged();
void backgroundColorChanged();
void foregroundColorChanged();
void progressColorChanged();
void textColorChanged();
void suffixTextChanged();
void penStyleChanged();
void dialTypeChanged();
void textFontChanged();
private:
qreal m_Size;
qreal m_StartAngle;
qreal m_SpanAngle;
qreal m_MinValue;
qreal m_MaxValue;
qreal m_Value;
int m_DialWidth;
QColor m_BackgroundColor;
QColor m_DialColor;
QColor m_ProgressColor;
QColor m_TextColor;
QString m_SuffixText;
bool m_ShowText;
Qt::PenCapStyle m_PenStyle;
DialType m_DialType;
QFont m_TextFont;
};
#endif // RADIALBAR_H