summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-08-19 17:26:29 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-09 20:05:03 +0200
commitc1d88b95f97a18443c60d62626e86b619cd84f34 (patch)
treed2eece6efeb388c2e9307e9298e4bc26f13a144a /src
parent66d9c281af9407d920f9cad7020f8314c9945a10 (diff)
BusyIndicator
A basic BusyIndicator to indicate activity while blocking the UI. Change-Id: Iec88b6a4c7f23b630ebdf445c4cb288684c24cb7 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/controls/BusyIndicator.qml76
-rw-r--r--src/controls/Styles/Base/BusyIndicatorStyle.qml128
-rw-r--r--src/controls/Styles/Desktop/BusyIndicatorStyle.qml42
-rw-r--r--src/controls/Styles/qmldir1
-rw-r--r--src/controls/Styles/styles.pri2
-rw-r--r--src/controls/controls.pro1
-rw-r--r--src/controls/plugin.cpp4
7 files changed, 253 insertions, 1 deletions
diff --git a/src/controls/BusyIndicator.qml b/src/controls/BusyIndicator.qml
new file mode 100644
index 000000000..bf8b09524
--- /dev/null
+++ b/src/controls/BusyIndicator.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.1
+import QtQuick.Controls.Private 1.0
+
+/*!
+ \qmltype BusyIndicator
+ \inqmlmodule QtQuick.Controls 1.1
+ \since QtQuick.Controls 1.1
+ \ingroup controls
+ \brief A busy indicator.
+
+ The busy indicator should be used to indicate activity while content is
+ being loaded or the UI is blocked waiting for a resource to become available.
+
+ You can create a custom appearance for a Busy Indicator by
+ assigning a \l BusyIndicatorStyle.
+ */
+Control {
+ id: indicator
+
+ /*! \qmlproperty bool BusyIndicator::running
+
+ This property holds whether the busy indicator is currently indicating
+ activity.
+
+ \note The indicator is only visible when this property is set to \c true.
+
+ The default value is \c true.
+ */
+ property bool running: true
+
+ Accessible.role: Accessible.Indicator
+ Accessible.name: "busy"
+
+ style: Qt.createComponent(Settings.style + "/BusyIndicatorStyle.qml", indicator)
+}
diff --git a/src/controls/Styles/Base/BusyIndicatorStyle.qml b/src/controls/Styles/Base/BusyIndicatorStyle.qml
new file mode 100644
index 000000000..e03748833
--- /dev/null
+++ b/src/controls/Styles/Base/BusyIndicatorStyle.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.1
+import QtQuick.Controls 1.1
+import QtQuick.Controls.Private 1.0
+
+/*!
+ \qmltype BusyIndicatorStyle
+ \inqmlmodule QtQuick.Controls.Styles 1.1
+ \since QtQuick.Controls.Styles 1.1
+ \ingroup controlsstyling
+ \brief Provides custom styling for BusyIndicatorStyle
+
+ You can create a busy indicator by replacing the "indicator" delegate
+ of the BusyIndicatorStyle with a custom design.
+
+ Example:
+ \qml
+ BusyIndicator {
+ style: BusyIndicatorStyle
+ indicator: Image {
+ visible: control.running
+ source: "spinner.png"
+ NumberAnimation on rotation {
+ running: control.running
+ loops: Animation.Infinite
+ duration: 2000
+ from: 0 ; to: 360
+ }
+ }
+ }
+ }
+ \endqml
+*/
+Style {
+ id: indicatorstyle
+
+ /*! The \l BusyIndicator attached to this style. */
+ readonly property BusyIndicator control: __control
+
+ /*! This defines the appearance of the busy indicator. */
+ property Component indicator: Item {
+ implicitWidth: 32
+ implicitHeight: 32
+
+ opacity: control.running ? 1 : 0
+ Behavior on opacity { NumberAnimation { duration: 250 } }
+
+ Timer {
+ interval: 16
+ running: control.running
+ repeat: true
+ onTriggered: { repeater.counter += 0.20 }
+ }
+
+ Repeater {
+ id: repeater
+ model: 9
+ anchors.fill: parent
+ property real counter: 0
+ Rectangle {
+ width: repeater.width/6 + 2
+ height: width
+ radius: width/2
+ x: repeater.width/2
+ transform: Rotation { origin.x: 0 ; origin.y: repeater.width/2 ; angle: 5 + (360/repeater.count) * index}
+ border.color: Qt.rgba(0, 0, 0, 0.24)
+ color: Qt.rgba(lum, lum, lum, lum/2 + 0.3)
+ property real lum: {
+ var idx = ((repeater.count-index) + repeater.counter) % repeater.count
+ return Math.max( 0.3, 1 - (idx/(repeater.count - 1)))
+ }
+ }
+ }
+ }
+
+ /*! \internal */
+ property Component panel: Item {
+ anchors.fill: parent
+ implicitWidth: indicatorLoader.implicitWidth
+ implicitHeight: indicatorLoader.implicitHeight
+
+ Loader {
+ id: indicatorLoader
+ sourceComponent: indicator
+ anchors.centerIn: parent
+ width: Math.min(parent.width, parent.height)
+ height: width
+ }
+ }
+}
diff --git a/src/controls/Styles/Desktop/BusyIndicatorStyle.qml b/src/controls/Styles/Desktop/BusyIndicatorStyle.qml
new file mode 100644
index 000000000..99f37919f
--- /dev/null
+++ b/src/controls/Styles/Desktop/BusyIndicatorStyle.qml
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick.Controls.Styles 1.1
+
+BusyIndicatorStyle { }
diff --git a/src/controls/Styles/qmldir b/src/controls/Styles/qmldir
index 5077542a5..8080acaf4 100644
--- a/src/controls/Styles/qmldir
+++ b/src/controls/Styles/qmldir
@@ -1,5 +1,6 @@
module QtQuick.Controls.Styles
ButtonStyle 1.0 Base/ButtonStyle.qml
+BusyIndicatorStyle 1.1 Base/BusyIndicatorStyle.qml
CheckBoxStyle 1.0 Base/CheckBoxStyle.qml
ComboBoxStyle 1.0 Base/ComboBoxStyle.qml
ProgressBarStyle 1.0 Base/ProgressBarStyle.qml
diff --git a/src/controls/Styles/styles.pri b/src/controls/Styles/styles.pri
index 10eb3e9b4..9cdd9c953 100644
--- a/src/controls/Styles/styles.pri
+++ b/src/controls/Styles/styles.pri
@@ -2,6 +2,7 @@
# Base
STYLES_QML_FILES = \
$$PWD/Base/ButtonStyle.qml \
+ $$PWD/Base/BusyIndicatorStyle.qml \
$$PWD/Base/CheckBoxStyle.qml \
$$PWD/Base/ComboBoxStyle.qml \
$$PWD/Base/FocusFrameStyle.qml \
@@ -23,6 +24,7 @@ STYLES_QML_FILES = \
# Desktop
STYLES_QML_FILES += \
$$PWD/Desktop/ButtonStyle.qml \
+ $$PWD/Desktop/BusyIndicatorStyle.qml \
$$PWD/Desktop/CheckBoxStyle.qml \
$$PWD/Desktop/ComboBoxStyle.qml \
$$PWD/Desktop/FocusFrameStyle.qml \
diff --git a/src/controls/controls.pro b/src/controls/controls.pro
index 380183530..37a5a32ab 100644
--- a/src/controls/controls.pro
+++ b/src/controls/controls.pro
@@ -9,6 +9,7 @@ QMAKE_DOCS = $$PWD/doc/qtquickcontrols.qdocconf
CONTROLS_QML_FILES = \
ApplicationWindow.qml \
Button.qml \
+ BusyIndicator.qml \
CheckBox.qml \
ComboBox.qml \
GroupBox.qml \
diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp
index b98e79080..6e0e1b045 100644
--- a/src/controls/plugin.cpp
+++ b/src/controls/plugin.cpp
@@ -91,7 +91,9 @@ static const struct {
{ "TextArea", 1, 0 },
{ "TextField", 1, 0 },
{ "ToolBar", 1, 0 },
- { "ToolButton", 1, 0 }
+ { "ToolButton", 1, 0 },
+
+ { "BusyIndicator", 1, 1 }
};
void QtQuickControlsPlugin::registerTypes(const char *uri)