-
Notifications
You must be signed in to change notification settings - Fork 18
/
ProgressCircle.h
91 lines (71 loc) · 2.19 KB
/
ProgressCircle.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
/////////////////////////////////////////////////////////////////////////////
// Date of creation: 04.07.2013
// Creator: Alexander Egorov aka mofr
// Authors: mofr
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QWidget>
#include <QPropertyAnimation>
class ProgressCircle : public QWidget
{
Q_OBJECT
Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(int maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
Q_PROPERTY(qreal innerRadius READ innerRadius WRITE setInnerRadius)
Q_PROPERTY(qreal outerRadius READ outerRadius WRITE setOuterRadius)
Q_PROPERTY(QColor color READ color WRITE setColor)
//private
Q_PROPERTY(qreal infiniteAnimationValue READ infiniteAnimationValue WRITE setInfiniteAnimationValue)
Q_PROPERTY(int visibleValue READ visibleValue WRITE setVisibleValue)
public:
explicit ProgressCircle(QWidget *parent = 0);
int value() const;
/**
* @brief maximum
* If maximum <= 0, widget shows infinite process;
* @return
*/
int maximum() const;
/**
* @brief innerRadius = [0.0 .. 1.0]
* @return
*/
qreal innerRadius() const;
/**
* @brief outerRadius = [0.0 .. 1.0]
* @return
*/
qreal outerRadius() const;
QColor color() const;
public slots:
void setValue(int value);
void setMaximum(int maximum);
void setInnerRadius(qreal innerRadius);
void setOuterRadius(qreal outerRadius);
void setColor(QColor color);
signals:
void valueChanged(int);
void maximumChanged(int);
protected:
void paintEvent(QPaintEvent *);
private slots:
void setInfiniteAnimationValue(qreal value);
void setVisibleValue(int value);
private:
QString key() const;
QPixmap generatePixmap() const;
qreal infiniteAnimationValue() const;
int visibleValue() const;
private:
//actual current value
int mValue;
int mMaximum;
qreal mInnerRadius;
qreal mOuterRadius;
QColor mColor;
//value visible to user
int mVisibleValue;
QPropertyAnimation mValueAnimation;
QPropertyAnimation mInfiniteAnimation;
qreal mInfiniteAnimationValue;
};