Skip to content

Commit 3bf773f

Browse files
committed
ProjectPlayer: Add loading progress indicators
1 parent 9712c99 commit 3bf773f

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

ScratchCPPGui/ProjectPlayer.qml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-License-Identifier: LGPL-3.0-or-later
22

33
import QtQuick
4+
import QtQuick.Layouts
5+
import QtQuick.Controls
46
import ScratchCPPGui
57

68
ProjectScene {
@@ -9,18 +11,30 @@ ProjectScene {
911
property alias turboMode: loader.turboMode
1012
property alias cloneLimit: loader.cloneLimit
1113
property alias spriteFencing: loader.spriteFencing
14+
property bool showLoadingProgress: true
15+
readonly property bool loading: priv.loading
16+
readonly property int downloadedAssets: loader.downloadedAssets
17+
readonly property int assetCount: loader.assetCount
1218
signal loaded()
1319
signal failedToLoad()
1420

1521
id: root
1622
clip: true
23+
onFileNameChanged: priv.loading = true;
24+
25+
QtObject {
26+
id: priv
27+
property bool loading: false
28+
}
1729

1830
ProjectLoader {
1931
id: loader
2032
fileName: root.fileName
2133
stageWidth: parent.width
2234
stageHeight: parent.height
2335
onLoadingFinished: {
36+
priv.loading = false;
37+
2438
if(loadStatus)
2539
loaded();
2640
else
@@ -55,4 +69,44 @@ ProjectScene {
5569
Component.onCompleted: modelData.renderedTarget = this
5670
}
5771
}
72+
73+
Loader {
74+
anchors.fill: parent
75+
active: showLoadingProgress && loading
76+
77+
sourceComponent: ColumnLayout {
78+
anchors.fill: parent
79+
80+
Item { Layout.fillHeight: true }
81+
82+
BusyIndicator {
83+
Layout.fillWidth: true
84+
Layout.maximumWidth: 100
85+
Layout.alignment: Qt.AlignHCenter
86+
running: true
87+
}
88+
89+
Label {
90+
Layout.alignment: Qt.AlignHCenter
91+
font.bold: true
92+
font.pointSize: 12
93+
text: {
94+
if(loading)
95+
return assetCount == downloadedAssets ? qsTr("Loading project...") : qsTr("Downloading assets... (%1 of %2)").arg(downloadedAssets).arg(assetCount);
96+
else
97+
return "";
98+
}
99+
}
100+
101+
ProgressBar {
102+
Layout.fillWidth: true
103+
from: 0
104+
to: assetCount
105+
value: downloadedAssets
106+
indeterminate: assetCount == downloadedAssets
107+
}
108+
109+
Item { Layout.fillHeight: true }
110+
}
111+
}
58112
}

0 commit comments

Comments
 (0)