42 setLoopCount(Infinite);
44 setCurrentTime(item->elapsed());
46 m_phases[0] = Phase(433, -110, 10, QEasingCurve::BezierSpline);
47 m_phases[1] = Phase(767, 10, 93, QEasingCurve::Linear );
48 m_phases[2] = Phase(417, 93, 205, QEasingCurve::BezierSpline);
49 m_phases[3] = Phase(400, 205, 357, QEasingCurve::BezierSpline);
50 m_phases[4] = Phase(766, 357, 439, QEasingCurve::Linear );
51 m_phases[5] = Phase(434, 439, 585, QEasingCurve::BezierSpline);
53 m_phases[0].curve.addCubicBezierSegment(QPointF(0.02, 0.33), QPointF(0.38, 0.77), QPointF(1.00, 1.00));
54 m_phases[2].curve.addCubicBezierSegment(QPointF(0.57, 0.17), QPointF(0.95, 0.75), QPointF(1.00, 1.00));
55 m_phases[3].curve.addCubicBezierSegment(QPointF(0.00, 0.19), QPointF(0.07, 0.72), QPointF(1.00, 1.00));
56 m_phases[5].curve.addCubicBezierSegment(QPointF(0.00, 0.00), QPointF(0.95, 0.37), QPointF(1.00, 1.00));
62 int count = childCount();
63 QSGTransformNode *transformNode =
static_cast<QSGTransformNode *>(firstChild());
64 while (transformNode) {
65 Q_ASSERT(transformNode->type() == QSGNode::TransformNodeType);
67 QSGOpacityNode *opacityNode =
static_cast<QSGOpacityNode *>(transformNode->firstChild());
68 Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
73 bool visible = time >= begin && time <= end;
74 opacityNode->setOpacity(visible ? 1.0 : 0.0);
77 int phaseIndex, remain = time, elapsed = 0;
78 for (phaseIndex = 0; phaseIndex <
PhaseCount - 1; ++phaseIndex) {
79 if (remain <= m_phases[phaseIndex].duration + begin)
81 remain -= m_phases[phaseIndex].duration;
82 elapsed += m_phases[phaseIndex].duration;
85 const Phase &phase = m_phases[phaseIndex];
87 qreal from = phase.from - nodeIndex * count;
88 qreal to = phase.to - nodeIndex * count;
89 qreal pos = time - elapsed - begin;
91 qreal value = phase.curve.valueForProgress(pos / phase.duration);
92 qreal rotation = from + (to - from) * value;
95 matrix.rotate(rotation, 0, 0, 1);
96 transformNode->setMatrix(matrix);
99 transformNode =
static_cast<QSGTransformNode *>(transformNode->nextSibling());
106 QQuickUniversalBusyIndicator *indicator =
static_cast<QQuickUniversalBusyIndicator *>(item);
107 QQuickItemPrivate *d = QQuickItemPrivate::get(item);
110 matrix.translate(item->width() / 2, item->height() / 2);
113 qreal size = qMin(item->width(), item->height());
114 qreal diameter = size / 10.0;
115 qreal radius = diameter / 2;
116 qreal offset = (size - diameter * 2) / M_PI;
117 const QRectF rect(offset, offset, diameter, diameter);
119 int count = indicator->count();
120 QSGNode *transformNode = firstChild();
121 for (
int i = 0; i < count; ++i) {
122 if (!transformNode) {
123 transformNode =
new QSGTransformNode;
124 appendChildNode(transformNode);
126 QSGOpacityNode *opacityNode =
new QSGOpacityNode;
127 transformNode->appendChildNode(opacityNode);
129 QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
130 rectNode->setAntialiasing(
true);
131 opacityNode->appendChildNode(rectNode);
134 QSGNode *opacityNode = transformNode->firstChild();
135 Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
137 QSGInternalRectangleNode *rectNode =
static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
138 Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
140 rectNode->setRect(rect);
141 rectNode->setColor(indicator->color());
142 rectNode->setRadius(radius);
145 transformNode = transformNode->nextSibling();
148 while (transformNode) {
149 QSGNode *nextSibling = transformNode->nextSibling();
150 delete transformNode;
151 transformNode = nextSibling;
194void QQuickUniversalBusyIndicator::itemChange(QQuickItem::ItemChange change,
const QQuickItem::ItemChangeData &data)
196 QQuickItem::itemChange(change, data);
197 if (change == ItemVisibleHasChanged)