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
4#include "qquickbusyindicator_p.h"
5#include "qquickcontrol_p_p.h"
6
7QT_BEGIN_NAMESPACE
8
9/*!
10 \qmltype BusyIndicator
11 \inherits Control
12//! \instantiates QQuickBusyIndicator
13 \inqmlmodule QtQuick.Controls
14 \since 5.7
15 \ingroup qtquickcontrols-indicators
16 \brief Indicates background activity, for example, while content is being loaded.
17
18 \image qtquickcontrols-busyindicator.gif
19
20 The busy indicator should be used to indicate activity while content is
21 being loaded or the UI is blocked waiting for a resource to become available.
22
23 The following snippet shows how to use the BusyIndicator:
24
25 \qml
26 BusyIndicator {
27 running: image.status === Image.Loading
28 }
29 \endqml
30
31 BusyIndicator is similar to an indeterminate \l ProgressBar. Both can be
32 used to indicate background activity. The main difference is visual, and
33 that ProgressBar can also present a concrete amount of progress (when it
34 can be determined). Due to the visual difference, busy indicators and
35 indeterminate progress bars fit different places in user interfaces.
36 Typical places for a busy indicator:
37 \list
38 \li in the corner of a \l ToolBar
39 \li as an overlay on top of a \l Page
40 \li on the side of an \l ItemDelegate
41 \endlist
42
43 \sa {Customizing BusyIndicator}, {Indicator Controls}, ProgressBar
44*/
45
46class QQuickBusyIndicatorPrivate : public QQuickControlPrivate
47{
48public:
49 bool running = true;
50};
51
52QQuickBusyIndicator::QQuickBusyIndicator(QQuickItem *parent)
53 : QQuickControl(*(new QQuickBusyIndicatorPrivate), parent)
54{
55}
56
57/*!
58 \qmlproperty bool QtQuick.Controls::BusyIndicator::running
59
60 This property holds whether the busy indicator is currently indicating
61 activity.
62
63 \note The indicator is only visible when this property is set to \c true.
64
65 The default value is \c true.
66*/
67bool QQuickBusyIndicator::isRunning() const
68{
69 Q_D(const QQuickBusyIndicator);
70 return d->running;
71}
72
73void QQuickBusyIndicator::setRunning(bool running)
74{
75 Q_D(QQuickBusyIndicator);
76 if (d->running == running)
77 return;
78
79 d->running = running;
80 emit runningChanged();
81}
82
83#if QT_CONFIG(quicktemplates2_multitouch)
84void QQuickBusyIndicator::touchEvent(QTouchEvent *event)
85{
86 event->ignore(); // QTBUG-61785
87}
88#endif
89
90#if QT_CONFIG(accessibility)
91QAccessible::Role QQuickBusyIndicator::accessibleRole() const
92{
93 return QAccessible::Indicator;
94}
95#endif
96
97QT_END_NAMESPACE
98
99#include "moc_qquickbusyindicator_p.cpp"
100

source code of qtdeclarative/src/quicktemplates/qquickbusyindicator.cpp