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
9
+
8
10
9
11
import "../controls"
10
12
11
13
ColumnLayout {
12
14
signal snapshotImportCompleted ()
13
15
property int snapshotVerificationCycles: 0
14
16
property real snapshotVerificationProgress: 0
15
- property bool snapshotVerified: false
17
+ property bool snapshotVerified: optionsModel . snapshotLoadCompleted
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 simulation timer before release
22
24
Timer {
23
25
id: snapshotSimulationTimer
24
26
interval: 50 // Update every 50ms
@@ -42,7 +44,7 @@ ColumnLayout {
42
44
43
45
StackLayout {
44
46
id: settingsStack
45
- currentIndex: 0
47
+ currentIndex: optionsModel . snapshotLoadCompleted ? 2 : 0
46
48
47
49
ColumnLayout {
48
50
Layout .alignment : Qt .AlignHCenter
@@ -78,8 +80,26 @@ 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
+ // TODO: Connect this to snapshot loading
84
+ // settingsStack.currentIndex = 1
85
+ fileDialog .open ()
86
+ }
87
+ }
88
+
89
+ FileDialog {
90
+ id: fileDialog
91
+ folder: shortcuts .home
92
+ selectMultiple: false
93
+ onAccepted: {
94
+ console .log (" File chosen:" , fileDialog .fileUrls )
95
+ var snapshotFileName = fileDialog .fileUrl .toString ()
96
+ console .log (" Snapshot file name:" , snapshotFileName)
97
+ if (snapshotFileName .endsWith (" .dat" )) {
98
+ // optionsModel.setSnapshotDirectory(snapshotFileName)
99
+ // console.log("Snapshot directory set:", optionsModel.getSnapshotDirectory())
100
+ optionsModel .initializeSnapshot (true , snapshotFileName)
101
+ settingsStack .currentIndex = 1
102
+ }
83
103
}
84
104
}
85
105
}
@@ -109,10 +129,27 @@ ColumnLayout {
109
129
Layout .topMargin : 20
110
130
width: 200
111
131
height: 20
112
- progress: snapshotVerificationProgress
132
+ progress: optionsModel . snapshotProgress
113
133
Layout .alignment : Qt .AlignCenter
114
134
progressColor: Theme .color .blue
115
135
}
136
+
137
+ Connections {
138
+ target: optionsModel
139
+ function onSnapshotProgressChanged () {
140
+ progressIndicator .progress = optionsModel .snapshotProgress
141
+ }
142
+ function onSnapshotLoadCompletedChanged (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
+ // You might want to show an error message or take other actions here
150
+ }
151
+ }
152
+ }
116
153
}
117
154
118
155
ColumnLayout {
@@ -137,8 +174,8 @@ ColumnLayout {
137
174
descriptionColor: Theme .color .neutral6
138
175
descriptionSize: 17
139
176
descriptionLineHeight: 1.1
140
- description: qsTr (" It contains transactions up to January 12, 2024 . Newer transactions still need to be downloaded." +
141
- " The data will be verified in the background." )
177
+ description: qsTr (" It contains transactions up to %1 . Newer transactions still need to be downloaded." +
178
+ " The data will be verified in the background." ). arg ( optionsModel . snapshotDate )
142
179
}
143
180
144
181
ContinueButton {
@@ -188,14 +225,17 @@ ColumnLayout {
188
225
font .pixelSize : 14
189
226
}
190
227
CoreText {
191
- text: qsTr (" 200,000" )
228
+ // text: qsTr("160,000")
229
+ text: optionsModel .snapshotBlockHeight .toLocaleString (Qt .locale (), ' f' , 0 )
192
230
Layout .alignment : Qt .AlignRight
193
231
font .pixelSize : 14
194
232
}
195
233
}
196
234
Separator { Layout .fillWidth : true }
197
235
CoreText {
198
- text: qsTr (" Hash: 0x1234567890abcdef..." )
236
+ // text: qsTr("Hash: 0x1234567890abcdef...")
237
+ // TODO: truncate the hash to 8 characters
238
+ text: qsTr (" Hash: %1" ).arg (optionsModel .snapshotBlockHash )
199
239
font .pixelSize : 14
200
240
}
201
241
}
0 commit comments