Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickfusionbusyindicator.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtGui/qpainter.h>
7
9
14
16{
17 return m_color;
18}
19
21{
22 if (color == m_color)
23 return;
24
25 m_color = color;
26 update();
27}
28
30{
31 return isVisible();
32}
33
35{
36 if (running) {
37 setVisible(true);
38 update();
39 }
40}
41
43{
44 const qreal w = width();
45 const qreal h = height();
46 if (w <= 0 || h <= 0 || !isRunning())
47 return;
48
49 const qreal sz = qMin(w, h);
50 const qreal dx = (w - sz) / 2;
51 const qreal dy = (h - sz) / 2;
52 const int hpw = qRound(qMax(qreal(1), sz / 14)) & -1;
53 const int pw = 2 * hpw;
54 const QRectF bounds(dx + hpw, dy + hpw, sz - pw - 1, sz - pw - 1);
55
56 QConicalGradient gradient;
57 gradient.setCenter(QPointF(dx + sz / 2, dy + sz / 2));
58 gradient.setColorAt(0, m_color);
59 gradient.setColorAt(0.1, m_color);
60 gradient.setColorAt(1, Qt::transparent);
61
62 painter->translate(0.5, 0.5);
64 painter->setPen(QPen(gradient, pw, Qt::SolidLine));
65 painter->drawArc(bounds, 0, 360 * 16);
67 painter->drawArc(bounds, 0, 20 * 16);
68}
69
71{
73
74 switch (change) {
76 if (qFuzzyIsNull(data.realValue))
77 setVisible(false);
78 break;
80 update();
81 break;
82 default:
83 break;
84 }
85}
86
88
89#include "moc_qquickfusionbusyindicator_p.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtGui
Definition qbrush.h:446
void setCenter(const QPointF &center)
Sets the center of this conical gradient in logical coordinates to center.
Definition qbrush.cpp:2439
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition qbrush.cpp:1563
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawArc(const QRectF &rect, int a, int alen)
Draws the arc defined by the given rectangle, startAngle and spanAngle.
@ Antialiasing
Definition qpainter.h:52
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
\inmodule QtGui
Definition qpen.h:28
\inmodule QtCore\reentrant
Definition qpoint.h:217
void setColor(const QColor &color)
QQuickFusionBusyIndicator(QQuickItem *parent=nullptr)
void paint(QPainter *painter) override
This function, which is usually called by the QML Scene Graph, paints the contents of an item in loca...
void itemChange(ItemChange change, const ItemChangeData &data) override
Called when change occurs for this item.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
bool isVisible() const
qreal width
This property holds the width of this item.
Definition qquickitem.h:75
void setVisible(bool)
qreal height
This property holds the height of this item.
Definition qquickitem.h:76
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:144
@ ItemVisibleHasChanged
Definition qquickitem.h:148
@ ItemOpacityHasChanged
Definition qquickitem.h:150
void update()
Schedules a call to updatePaintNode() for this item.
The QQuickPaintedItem class provides a way to use the QPainter API in the QML Scene Graph.
void itemChange(ItemChange, const ItemChangeData &) override
\reimp
\inmodule QtCore\reentrant
Definition qrect.h:484
Combined button and popup list for selecting options.
@ transparent
Definition qnamespace.h:47
@ SolidLine
@ RoundCap
static Q_CONSTINIT QBasicAtomicInt running
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:327
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint color
[2]
GLfloat GLfloat GLfloat GLfloat h
double qreal
Definition qtypes.h:187
QPainter painter(this)
[7]
\inmodule QtQuick
Definition qquickitem.h:159