1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#include "qquickbusyindicator_p.h"
38#include "qquickcontrol_p_p.h"
39
40QT_BEGIN_NAMESPACE
41
42/*!
43 \qmltype BusyIndicator
44 \inherits Control
45//! \instantiates QQuickBusyIndicator
46 \inqmlmodule QtQuick.Controls
47 \since 5.7
48 \ingroup qtquickcontrols2-indicators
49 \brief Indicates background activity, for example, while content is being loaded.
50
51 \image qtquickcontrols2-busyindicator.gif
52
53 The busy indicator should be used to indicate activity while content is
54 being loaded or the UI is blocked waiting for a resource to become available.
55
56 The following snippet shows how to use the BusyIndicator:
57
58 \qml
59 BusyIndicator {
60 running: image.status === Image.Loading
61 }
62 \endqml
63
64 BusyIndicator is similar to an indeterminate \l ProgressBar. Both can be
65 used to indicate background activity. The main difference is visual, and
66 that ProgressBar can also present a concrete amount of progress (when it
67 can be determined). Due to the visual difference, busy indicators and
68 indeterminate progress bars fit different places in user interfaces.
69 Typical places for a busy indicator:
70 \list
71 \li in the corner of a \l ToolBar
72 \li as an overlay on top of a \l Page
73 \li on the side of an \l ItemDelegate
74 \endlist
75
76 \sa {Customizing BusyIndicator}, {Indicator Controls}, ProgressBar
77*/
78
79class QQuickBusyIndicatorPrivate : public QQuickControlPrivate
80{
81public:
82 bool running = true;
83};
84
85QQuickBusyIndicator::QQuickBusyIndicator(QQuickItem *parent)
86 : QQuickControl(*(new QQuickBusyIndicatorPrivate), parent)
87{
88}
89
90/*!
91 \qmlproperty bool QtQuick.Controls::BusyIndicator::running
92
93 This property holds whether the busy indicator is currently indicating
94 activity.
95
96 \note The indicator is only visible when this property is set to \c true.
97
98 The default value is \c true.
99*/
100bool QQuickBusyIndicator::isRunning() const
101{
102 Q_D(const QQuickBusyIndicator);
103 return d->running;
104}
105
106void QQuickBusyIndicator::setRunning(bool running)
107{
108 Q_D(QQuickBusyIndicator);
109 if (d->running == running)
110 return;
111
112 d->running = running;
113 emit runningChanged();
114}
115
116#if QT_CONFIG(quicktemplates2_multitouch)
117void QQuickBusyIndicator::touchEvent(QTouchEvent *event)
118{
119 event->ignore(); // QTBUG-61785
120}
121#endif
122
123#if QT_CONFIG(accessibility)
124QAccessible::Role QQuickBusyIndicator::accessibleRole() const
125{
126 return QAccessible::Indicator;
127}
128#endif
129
130QT_END_NAMESPACE
131

source code of qtquickcontrols2/src/quicktemplates2/qquickbusyindicator.cpp