-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathradialbar.h
More file actions
134 lines (123 loc) · 5.29 KB
/
radialbar.h
File metadata and controls
134 lines (123 loc) · 5.29 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*************************************************************************************
** The MIT License (MIT)
**
** RadialBar is a free Qt and QML based component.
** Copyright (c) 2017 Arun PK
** Email: mailztopk@gmail.com
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in all
** copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
************************************************************************************/
#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