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