5#include <QtGui/QPolygonF>
6#include <QtQml/QQmlEngine>
8#include "qml_material/core.hpp"
13class LoadingIndicatorUpdator :
public QObject {
18 Q_PROPERTY(QPolygonF currentShape READ currentShape NOTIFY updated FINAL)
19 Q_PROPERTY(
double rotation READ rotation NOTIFY updated FINAL)
20 Q_PROPERTY(QColor color READ color NOTIFY updated FINAL)
21 Q_PROPERTY(
double morphFraction READ morphFraction NOTIFY updated FINAL)
24 Q_PROPERTY(
double progress READ progress WRITE setProgress NOTIFY updated FINAL)
27 Q_PROPERTY(QList<QColor> colors READ colors WRITE setColors NOTIFY colorsChanged FINAL)
30 Q_PROPERTY(
int shapeCount READ shapeCount CONSTANT FINAL)
31 Q_PROPERTY(
int msPerShape READ msPerShape CONSTANT FINAL)
34 explicit LoadingIndicatorUpdator(QObject* parent =
nullptr);
37 auto currentShape() const noexcept -> QPolygonF;
38 auto rotation() const noexcept ->
double;
39 auto color() const noexcept -> QColor;
40 auto morphFraction() const noexcept ->
double;
43 auto progress() const noexcept ->
double;
44 void setProgress(
double p);
47 auto colors() const -> QList<QColor>;
48 void setColors(const QList<QColor>& colors);
51 static
int shapeCount() {
return SHAPE_COUNT; }
52 static int msPerShape() {
return MS_PER_SHAPE; }
54 Q_SIGNAL
void updated();
55 Q_SIGNAL
void colorsChanged();
58 void updateInternal() noexcept;
60 auto interpolateShapes(const QPolygonF& s1, const QPolygonF& s2,
61 double t) const -> QPolygonF;
65 double m_morph_fraction;
68 QList<QColor> m_colors;
71 QList<QPolygonF> m_predefined_shapes;
72 QList<QPolygonF> m_aligned_shapes;
75 static constexpr
int SHAPE_COUNT = 7;
76 static constexpr
int SAMPLE_COUNT = 64;
77 static constexpr
int MS_PER_SHAPE = 650;