Warning, /education/gcompris/src/core/Loading.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - Loading.qml 0002 * 0003 * SPDX-FileCopyrightText: 2015 Holger Kaelberer <holger.k@elberer.de> 0004 * 0005 * Authors: 0006 * Holger Kaelberer <holger.k@elberer.de> 0007 * 0008 * SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 import QtQuick 2.12 0011 import GCompris 1.0 0012 0013 /** 0014 * A QML component presenting a loading overlay to the user 0015 * 0016 * Should be used whenever the application is performing heavy work, that 0017 * would lead to a freeze in the GUI. The interface is simple: 0018 * <ul> 0019 * <li> 0020 start() starts the loading overlay. As a result interaction with the ui 0021 * is no longer possible (via touch/mouse) except for key event handling. 0022 * </li> 0023 * <li> 0024 * stop() stops the loading overlay. A user must take care to call stop() 0025 * in all possible (also error-) cases or the application never leaves 0026 * the loading overlay again. 0027 * </li> 0028 * </ul> 0029 * 0030 * There should be only one single Loading object anchored in the main window 0031 * as a sibling to the page stack. Activities are supposed to use this single 0032 * instance via the ActivityBase.loading property. 0033 * 0034 * Note that you can't use the loading animation to signal heavy ui changes that are 0035 * issued synchronously as the QML scene won't be updated fast enough to 0036 * even show the loading item. Therefore, to avoid freezing the ui, use... 0037 * <ul> 0038 * <li> 0039 * ... WorkerScript-s for ListModel based ui changes and 0040 * </li> 0041 * <li> 0042 * ... Component.incubateObject() for dynamic ui changes object creation 0043 * </li> 0044 * </ul> 0045 */ 0046 Item { 0047 id: root 0048 0049 /** 0050 * type:bool 0051 * Whether the loading icon is active. 0052 */ 0053 property bool active: false 0054 0055 /** 0056 * Start the loading overlay. 0057 */ 0058 function start() { 0059 visible = true; 0060 active = true; 0061 } 0062 0063 /** 0064 * Stop the loading overlay. 0065 */ 0066 function stop() { 0067 active = false; 0068 visible = false; 0069 if(ApplicationSettings.isKioskMode) { 0070 ActivityInfoTree.startingActivity = ""; 0071 } 0072 } 0073 0074 anchors.fill: parent 0075 z: 10001 // should be the highest value in the whole scene 0076 0077 visible: false 0078 0079 MultiPointTouchArea { 0080 // Just to catch mouse events 0081 anchors.fill: parent 0082 } 0083 0084 Rectangle { 0085 visible: ActivityInfoTree.startingActivity === "" 0086 anchors.fill: parent 0087 opacity: 0.8 0088 color: "grey" 0089 } 0090 0091 Image { 0092 id: loadingImage 0093 source: "qrc:/gcompris/src/core/resource/loading.svg" 0094 anchors.centerIn: parent 0095 sourceSize.width: 150 0096 width: sourceSize.width 0097 height: sourceSize.width 0098 opacity: 0.8 0099 0100 RotationAnimation on rotation { 0101 id: rotation 0102 running: root.active 0103 from: 0 0104 to: 360 0105 loops: Animation.Infinite 0106 duration: 1500 0107 } 0108 } 0109 }