QmlMaterial 0.1.0
Loading...
Searching...
No Matches
loading_indicator_updator.hpp
1#pragma once
2
3#include <QtGui/QColor>
4#include "qml_material/shape/material_shapes.hpp"
5
6namespace qml_material
7{
8
9class QML_MATERIAL_API LoadingIndicatorUpdator : public QObject {
10 Q_OBJECT
11 QML_ELEMENT
12 Q_PROPERTY(MaterialShape::Type shape READ shape NOTIFY updated FINAL)
13 Q_PROPERTY(MaterialShape::Type toShape READ toShape NOTIFY updated FINAL)
14 Q_PROPERTY(double shapeProgress READ shapeProgress NOTIFY updated FINAL)
15 Q_PROPERTY(double rotation READ rotation NOTIFY updated FINAL)
16 Q_PROPERTY(QColor color READ color NOTIFY updated FINAL)
17 Q_PROPERTY(double morphFraction READ progress NOTIFY updated FINAL)
18 Q_PROPERTY(double progress READ progress WRITE setProgress NOTIFY updated FINAL)
19 Q_PROPERTY(QList<QColor> colors READ colors WRITE setColors NOTIFY colorsChanged FINAL)
20 Q_PROPERTY(int shapeCount READ shapeCount CONSTANT FINAL)
21 Q_PROPERTY(int msPerShape READ msPerShape CONSTANT FINAL)
22public:
23 explicit LoadingIndicatorUpdator(QObject* parent = nullptr);
24 MaterialShape::Type shape() const;
25 MaterialShape::Type toShape() const;
26 double shapeProgress() const { return m_shapeProgress; }
27 double rotation() const { return m_rotation; }
28 QColor color() const { return m_color; }
29 double progress() const { return m_progress; }
30 void setProgress(double progress);
31 QList<QColor> colors() const { return m_colors; }
32 void setColors(const QList<QColor>& colors);
33 static int shapeCount() { return int(MaterialShapes::loadingSequence().size()); }
34 static int msPerShape() { return 650; }
35 Q_SIGNAL void updated();
36 Q_SIGNAL void colorsChanged();
37
38private:
39 void updateInternal();
40 double m_progress = 0;
41 double m_shapeProgress = 0;
42 double m_rotation = 0;
43 QColor m_color = Qt::transparent;
44 QList<QColor> m_colors;
45};
46
47} // namespace qml_material