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
- signal snapshotImportCompleted ()
13
- property int snapshotVerificationCycles: 0
14
- property real snapshotVerificationProgress: 0
15
- property bool snapshotVerified: false
16
-
17
13
id: columnLayout
14
+ property bool snapshotLoading: nodeModel .snapshotLoading
15
+ property bool snapshotLoaded: nodeModel .isSnapshotLoaded
16
+ property bool snapshotImportCompleted: chainModel .isSnapshotActive
17
+ property bool onboarding: false
18
+ property bool snapshotVerified: onboarding ? false : chainModel .isSnapshotActive
19
+ property string snapshotFileName: " "
20
+ property var snapshotInfo: ({})
21
+ property string selectedFile: " "
22
+
18
23
width: Math .min (parent .width , 450 )
19
24
anchors .horizontalCenter : parent .horizontalCenter
20
25
21
-
22
- Timer {
23
- id: snapshotSimulationTimer
24
- interval: 50 // Update every 50ms
25
- running: false
26
- repeat: true
27
- onTriggered: {
28
- if (snapshotVerificationProgress < 1 ) {
29
- snapshotVerificationProgress += 0.01
30
- } else {
31
- snapshotVerificationCycles++
32
- if (snapshotVerificationCycles < 1 ) {
33
- snapshotVerificationProgress = 0
34
- } else {
35
- running = false
36
- snapshotVerified = true
37
- settingsStack .currentIndex = 2
38
- }
39
- }
40
- }
41
- }
42
-
43
26
StackLayout {
44
27
id: settingsStack
45
- currentIndex: 0
28
+ currentIndex: onboarding ? 0 : snapshotLoaded ? 2 : snapshotVerified ? 2 : snapshotLoading ? 1 : 0
46
29
47
30
ColumnLayout {
48
31
Layout .alignment : Qt .AlignHCenter
@@ -77,11 +60,22 @@ ColumnLayout {
77
60
Layout .bottomMargin : 20
78
61
Layout .alignment : Qt .AlignCenter
79
62
text: qsTr (" Choose snapshot file" )
80
- onClicked: {
81
- settingsStack .currentIndex = 1
82
- snapshotSimulationTimer .start ()
63
+ onClicked: fileDialog .open ()
64
+ }
65
+
66
+ FileDialog {
67
+ id: fileDialog
68
+ folder: shortcuts .home
69
+ selectMultiple: false
70
+ selectExisting: true
71
+ nameFilters: [" Snapshot files (*.dat)" , " All files (*)" ]
72
+ onAccepted: {
73
+ selectedFile = fileUrl .toString ()
74
+ snapshotFileName = selectedFile
75
+ nodeModel .initializeSnapshot (true , snapshotFileName)
83
76
}
84
77
}
78
+ // TODO: Handle file error signal
85
79
}
86
80
87
81
ColumnLayout {
@@ -102,17 +96,10 @@ ColumnLayout {
102
96
Layout .leftMargin : 20
103
97
Layout .rightMargin : 20
104
98
header: qsTr (" Loading Snapshot" )
99
+ description: qsTr (" This might take a while..." )
105
100
}
106
101
107
- ProgressIndicator {
108
- id: progressIndicator
109
- Layout .topMargin : 20
110
- width: 200
111
- height: 20
112
- progress: snapshotVerificationProgress
113
- Layout .alignment : Qt .AlignCenter
114
- progressColor: Theme .color .blue
115
- }
102
+ // TODO: add progress indicator once the snapshot progress is implemented
116
103
}
117
104
118
105
ColumnLayout {
@@ -137,8 +124,11 @@ ColumnLayout {
137
124
descriptionColor: Theme .color .neutral6
138
125
descriptionSize: 17
139
126
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." )
127
+ description: snapshotInfo && snapshotInfo[" date" ] ?
128
+ qsTr (" It contains transactions up to %1. Newer transactions still need to be downloaded." +
129
+ " The data will be verified in the background." ).arg (snapshotInfo[" date" ]) :
130
+ qsTr (" It contains transactions up to DEBUG. Newer transactions still need to be downloaded." +
131
+ " The data will be verified in the background." )
142
132
}
143
133
144
134
ContinueButton {
@@ -147,7 +137,6 @@ ColumnLayout {
147
137
Layout .alignment : Qt .AlignCenter
148
138
text: qsTr (" Done" )
149
139
onClicked: {
150
- snapshotImportCompleted ()
151
140
connectionSwipe .decrementCurrentIndex ()
152
141
connectionSwipe .decrementCurrentIndex ()
153
142
}
@@ -188,16 +177,25 @@ ColumnLayout {
188
177
font .pixelSize : 14
189
178
}
190
179
CoreText {
191
- text: qsTr (" 200,000" )
180
+ text: snapshotInfo && snapshotInfo[" height" ] ?
181
+ snapshotInfo[" height" ] : qsTr (" DEBUG" )
192
182
Layout .alignment : Qt .AlignRight
193
183
font .pixelSize : 14
194
184
}
195
185
}
196
186
Separator { Layout .fillWidth : true }
197
187
CoreText {
198
- text: qsTr (" Hash: 0x1234567890abcdef..." )
188
+ text: snapshotInfo && snapshotInfo[" hashSerialized" ] ?
189
+ qsTr (" Hash: %1" ).arg (snapshotInfo[" hashSerialized" ].substring (0 , 13 ) + " ..." ) :
190
+ qsTr (" Hash: DEBUG" )
199
191
font .pixelSize : 14
200
192
}
193
+
194
+ Component .onCompleted : {
195
+ if (snapshotVerified || snapshotLoaded) {
196
+ snapshotInfo = chainModel .getSnapshotInfo ()
197
+ }
198
+ }
201
199
}
202
200
}
203
201
}
0 commit comments