11#include " qtmaterialcircularprogress.h"
2+ #include " lib/qtmaterialstyle.h"
3+ #include " qtmaterialcircularprogress_internal.h"
24#include " qtmaterialcircularprogress_p.h"
3- #include < QPropertyAnimation>
4- #include < QParallelAnimationGroup>
55#include < QPainter>
66#include < QPainterPath>
7- #include " qtmaterialcircularprogress_internal.h "
8- #include " lib/qtmaterialstyle.h "
7+ #include < QParallelAnimationGroup >
8+ #include < QPropertyAnimation >
99
1010/* !
1111 * \class QtMaterialCircularProgressPrivate
@@ -17,22 +17,19 @@ QtMaterialCircularProgressPrivate::QtMaterialCircularProgressPrivate(QtMaterialC
1717{
1818}
1919
20- QtMaterialCircularProgressPrivate::~QtMaterialCircularProgressPrivate ()
21- {
22- }
20+ QtMaterialCircularProgressPrivate::~QtMaterialCircularProgressPrivate () {}
2321
2422void QtMaterialCircularProgressPrivate::init ()
2523{
2624 Q_Q (QtMaterialCircularProgress);
2725
28- delegate = new QtMaterialCircularProgressDelegate (q);
29- progressType = Material::IndeterminateProgress;
30- penWidth = 6.25 ;
31- size = 64 ;
26+ delegate = new QtMaterialCircularProgressDelegate (q);
27+ progressType = Material::IndeterminateProgress;
28+ penWidth = 6.25 ;
29+ size = 64 ;
3230 useThemeColors = true ;
3331
34- q->setSizePolicy (QSizePolicy (QSizePolicy::MinimumExpanding,
35- QSizePolicy::MinimumExpanding));
32+ q->setSizePolicy (QSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
3633
3734 QParallelAnimationGroup *group = new QParallelAnimationGroup (q);
3835 group->setLoopCount (-1 );
@@ -82,15 +79,13 @@ void QtMaterialCircularProgressPrivate::init()
8279 */
8380
8481QtMaterialCircularProgress::QtMaterialCircularProgress (QWidget *parent)
85- : QProgressBar(parent),
86- d_ptr(new QtMaterialCircularProgressPrivate(this ))
82+ : QProgressBar(parent)
83+ , d_ptr(new QtMaterialCircularProgressPrivate(this ))
8784{
8885 d_func ()->init ();
8986}
9087
91- QtMaterialCircularProgress::~QtMaterialCircularProgress ()
92- {
93- }
88+ QtMaterialCircularProgress::~QtMaterialCircularProgress () {}
9489
9590void QtMaterialCircularProgress::setProgressType (Material::ProgressType type)
9691{
@@ -186,7 +181,7 @@ QSize QtMaterialCircularProgress::sizeHint() const
186181{
187182 Q_D (const QtMaterialCircularProgress);
188183
189- const qreal s = d->size + d->penWidth + 8 ;
184+ const qreal s = d->size + d->penWidth + 8 ;
190185 return QSize (s, s);
191186}
192187
@@ -202,21 +197,19 @@ void QtMaterialCircularProgress::paintEvent(QPaintEvent *event)
202197 QPainter painter (this );
203198 painter.setRenderHint (QPainter::Antialiasing);
204199
205- if (!isEnabled ())
206- {
200+ if (!isEnabled ()) {
207201 QPen pen;
208202 pen.setCapStyle (Qt::RoundCap);
209203 pen.setWidthF (d->penWidth );
210204 pen.setColor (QtMaterialStyle::instance ().themeColor (" border" ));
211205 painter.setPen (pen);
212- painter.drawLine (rect ().center ()- QPointF (20 , 20 ), rect ().center ()+ QPointF (20 , 20 ));
213- painter.drawLine (rect ().center ()+ QPointF (20 , -20 ), rect ().center ()- QPointF (20 , -20 ));
206+ painter.drawLine (rect ().center () - QPointF (20 , 20 ), rect ().center () + QPointF (20 , 20 ));
207+ painter.drawLine (rect ().center () + QPointF (20 , -20 ), rect ().center () - QPointF (20 , -20 ));
214208 return ;
215209 }
216210
217- if (Material::IndeterminateProgress == d->progressType )
218- {
219- painter.translate (width ()/2.0 , height ()/2.0 );
211+ if (Material::IndeterminateProgress == d->progressType ) {
212+ painter.translate (width () / 2.0 , height () / 2.0 );
220213 painter.rotate (d->delegate ->angle ());
221214 }
222215
@@ -225,26 +218,23 @@ void QtMaterialCircularProgress::paintEvent(QPaintEvent *event)
225218 pen.setWidthF (d->penWidth );
226219 pen.setColor (color ());
227220
228- if (Material::IndeterminateProgress == d->progressType )
229- {
221+ if (Material::IndeterminateProgress == d->progressType ) {
230222 QVector<qreal> pattern;
231- pattern << d->delegate ->dashLength ()* d->size / 50 << 30.0 * d->size / 50 ;
223+ pattern << d->delegate ->dashLength () * d->size / 50 << 30.0 * d->size / 50 ;
232224
233- pen.setDashOffset (d->delegate ->dashOffset ()* d->size / 50 );
225+ pen.setDashOffset (d->delegate ->dashOffset () * d->size / 50 );
234226 pen.setDashPattern (pattern);
235227
236228 painter.setPen (pen);
237229
238- painter.drawEllipse (QPoint (0 , 0 ), d->size /2 , d->size /2 );
239- }
240- else
241- {
230+ painter.drawEllipse (QPoint (0 , 0 ), d->size / 2 , d->size / 2 );
231+ } else {
242232 painter.setPen (pen);
243233
244- const qreal x = (width ()- d->size )/ 2.0 ;
245- const qreal y = (height ()- d->size )/ 2.0 ;
234+ const qreal x = (width () - d->size ) / 2.0 ;
235+ const qreal y = (height () - d->size ) / 2.0 ;
246236
247- const qreal a = 360.0 * (value ()- minimum ())/ (maximum ()- minimum ());
237+ const qreal a = 360.0 * (value () - minimum ()) / (maximum () - minimum ());
248238
249239 QPainterPath path;
250240 path.arcMoveTo (x, y, d->size , d->size , 0 );
0 commit comments