55import QtQuick 2.15
66import QtQuick.Controls 2.15
77import QtQuick.Layouts 1.15
8+ import QtQuick.Dialogs 1.3
89
910import "../controls"
1011
1112ColumnLayout {
1213 signal snapshotImportCompleted ()
1314 property int snapshotVerificationCycles: 0
1415 property real snapshotVerificationProgress: 0
15- property bool snapshotVerified: false
16+ property bool onboarding: false
17+ property bool snapshotVerified: onboarding ? false : chainModel .isSnapshotActive
1618
1719 id: columnLayout
1820 width: Math .min (parent .width , 450 )
1921 anchors .horizontalCenter : parent .horizontalCenter
2022
21-
23+ // TODO: Remove this once the verification progress is available
2224 Timer {
2325 id: snapshotSimulationTimer
2426 interval: 50 // Update every 50ms
@@ -29,7 +31,7 @@ ColumnLayout {
2931 snapshotVerificationProgress += 0.01
3032 } else {
3133 snapshotVerificationCycles++
32- if (snapshotVerificationCycles < 1 ) {
34+ if (snapshotVerificationCycles < 3 ) {
3335 snapshotVerificationProgress = 0
3436 } else {
3537 running = false
@@ -42,7 +44,7 @@ ColumnLayout {
4244
4345 StackLayout {
4446 id: settingsStack
45- currentIndex: 0
47+ currentIndex: onboarding ? 0 : snapshotVerified ? 2 : 0
4648
4749 ColumnLayout {
4850 Layout .alignment : Qt .AlignHCenter
@@ -78,8 +80,22 @@ ColumnLayout {
7880 Layout .alignment : Qt .AlignCenter
7981 text: qsTr (" Choose snapshot file" )
8082 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+ }
8399 }
84100 }
85101 }
@@ -109,10 +125,31 @@ ColumnLayout {
109125 Layout .topMargin : 20
110126 width: 200
111127 height: 20
112- progress: snapshotVerificationProgress
128+ // TODO: uncomment this once the verification progress is available
129+ // progress: nodeModel.verificationProgress
130+ progress: 0
113131 Layout .alignment : Qt .AlignCenter
114132 progressColor: Theme .color .blue
115133 }
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+ }
116153 }
117154
118155 ColumnLayout {
@@ -137,6 +174,7 @@ ColumnLayout {
137174 descriptionColor: Theme .color .neutral6
138175 descriptionSize: 17
139176 descriptionLineHeight: 1.1
177+ // TODO: Update this description once the snapshot is verified
140178 description: qsTr (" It contains transactions up to January 12, 2024. Newer transactions still need to be downloaded." +
141179 " The data will be verified in the background." )
142180 }
@@ -153,6 +191,9 @@ ColumnLayout {
153191 }
154192 }
155193
194+ // TODO: Update this with the actual snapshot details
195+ // TODO: uncomment this once the snapshot details are available
196+ /*
156197 Setting {
157198 id: viewDetails
158199 Layout.alignment: Qt.AlignCenter
@@ -188,17 +229,20 @@ ColumnLayout {
188229 font.pixelSize: 14
189230 }
190231 CoreText {
232+ // TODO: Update this with the actual block height
191233 text: qsTr("200,000")
192234 Layout.alignment: Qt.AlignRight
193235 font.pixelSize: 14
194236 }
195237 }
196238 Separator { Layout.fillWidth: true }
197239 CoreText {
240+ // TODO: Update this with the actual snapshot file hash
198241 text: qsTr("Hash: 0x1234567890abcdef...")
199242 font.pixelSize: 14
200243 }
201244 }
245+ */
202246 }
203247 }
204248}
0 commit comments