5
5
import QtQuick 2.15
6
6
import QtQuick.Controls 2.15
7
7
import QtQuick.Layouts 1.15
8
+ import QtQuick.Dialogs 1.3
8
9
9
10
import "../controls"
10
11
11
12
ColumnLayout {
12
13
signal snapshotImportCompleted ()
13
14
property int snapshotVerificationCycles: 0
14
15
property real snapshotVerificationProgress: 0
15
- property bool snapshotVerified: false
16
+ property bool onboarding: false
17
+ property bool snapshotVerified: onboarding ? false : chainModel .isSnapshotActive
16
18
17
19
id: columnLayout
18
20
width: Math .min (parent .width , 450 )
19
21
anchors .horizontalCenter : parent .horizontalCenter
20
22
21
-
23
+ // TODO: Remove this once the verification progress is available
22
24
Timer {
23
25
id: snapshotSimulationTimer
24
26
interval: 50 // Update every 50ms
@@ -29,7 +31,7 @@ ColumnLayout {
29
31
snapshotVerificationProgress += 0.01
30
32
} else {
31
33
snapshotVerificationCycles++
32
- if (snapshotVerificationCycles < 1 ) {
34
+ if (snapshotVerificationCycles < 3 ) {
33
35
snapshotVerificationProgress = 0
34
36
} else {
35
37
running = false
@@ -42,7 +44,7 @@ ColumnLayout {
42
44
43
45
StackLayout {
44
46
id: settingsStack
45
- currentIndex: 0
47
+ currentIndex: onboarding ? 0 : snapshotVerified ? 2 : 0
46
48
47
49
ColumnLayout {
48
50
Layout .alignment : Qt .AlignHCenter
@@ -78,8 +80,22 @@ ColumnLayout {
78
80
Layout .alignment : Qt .AlignCenter
79
81
text: qsTr (" Choose snapshot file" )
80
82
onClicked: {
81
- settingsStack .currentIndex = 1
82
- snapshotSimulationTimer .start ()
83
+ fileDialog .open ()
84
+ }
85
+ }
86
+
87
+ FileDialog {
88
+ id: fileDialog
89
+ folder: shortcuts .home
90
+ selectMultiple: false
91
+ onAccepted: {
92
+ console .log (" File chosen:" , fileDialog .fileUrls )
93
+ var snapshotFileName = fileDialog .fileUrl .toString ()
94
+ console .log (" Snapshot file name:" , snapshotFileName)
95
+ if (snapshotFileName .endsWith (" .dat" )) {
96
+ nodeModel .initializeSnapshot (true , snapshotFileName)
97
+ settingsStack .currentIndex = 1
98
+ }
83
99
}
84
100
}
85
101
}
@@ -109,10 +125,31 @@ ColumnLayout {
109
125
Layout .topMargin : 20
110
126
width: 200
111
127
height: 20
112
- progress: snapshotVerificationProgress
128
+ // TODO: uncomment this once the verification progress is available
129
+ // progress: nodeModel.verificationProgress
130
+ progress: 0
113
131
Layout .alignment : Qt .AlignCenter
114
132
progressColor: Theme .color .blue
115
133
}
134
+
135
+ Connections {
136
+ target: nodeModel
137
+ // TODO: uncomment this once the verification progress is available
138
+ // function onVerificationProgressChanged() {
139
+ // progressIndicator.progress = nodeModel.verificationProgress
140
+ // }
141
+ function onSnapshotLoaded (success ) {
142
+ if (success) {
143
+ chainModel .isSnapshotActiveChanged ()
144
+ snapshotVerified = chainModel .isSnapshotActive
145
+ progressIndicator .progress = 1
146
+ settingsStack .currentIndex = 2 // Move to the "Snapshot Loaded" page
147
+ } else {
148
+ // Handle snapshot loading failure
149
+ console .error (" Snapshot loading failed" )
150
+ }
151
+ }
152
+ }
116
153
}
117
154
118
155
ColumnLayout {
@@ -137,6 +174,7 @@ ColumnLayout {
137
174
descriptionColor: Theme .color .neutral6
138
175
descriptionSize: 17
139
176
descriptionLineHeight: 1.1
177
+ // TODO: Update this description once the snapshot is verified
140
178
description: qsTr (" It contains transactions up to January 12, 2024. Newer transactions still need to be downloaded." +
141
179
" The data will be verified in the background." )
142
180
}
@@ -153,6 +191,9 @@ ColumnLayout {
153
191
}
154
192
}
155
193
194
+ // TODO: Update this with the actual snapshot details
195
+ // TODO: uncomment this once the snapshot details are available
196
+ /*
156
197
Setting {
157
198
id: viewDetails
158
199
Layout.alignment: Qt.AlignCenter
@@ -188,17 +229,20 @@ ColumnLayout {
188
229
font.pixelSize: 14
189
230
}
190
231
CoreText {
232
+ // TODO: Update this with the actual block height
191
233
text: qsTr("200,000")
192
234
Layout.alignment: Qt.AlignRight
193
235
font.pixelSize: 14
194
236
}
195
237
}
196
238
Separator { Layout.fillWidth: true }
197
239
CoreText {
240
+ // TODO: Update this with the actual snapshot file hash
198
241
text: qsTr("Hash: 0x1234567890abcdef...")
199
242
font.pixelSize: 14
200
243
}
201
244
}
245
+ */
202
246
}
203
247
}
204
248
}
0 commit comments