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
+ signal back
15
+ property bool snapshotLoading: nodeModel .snapshotLoading
16
+ property bool snapshotLoaded: nodeModel .isSnapshotLoaded
17
+ property bool snapshotImportCompleted: onboarding ? false : chainModel .isSnapshotActive
18
+ property bool onboarding: false
19
+ property bool snapshotVerified: onboarding ? false : chainModel .isSnapshotActive
20
+ property string snapshotFileName: " "
21
+ property var snapshotInfo: (snapshotVerified || snapshotLoaded) ? chainModel .getSnapshotInfo () : ({})
22
+ property string selectedFile: " "
23
+ property bool headersSynced: nodeModel .headersSynced
24
+
18
25
width: Math .min (parent .width , 450 )
19
26
anchors .horizontalCenter : parent .horizontalCenter
20
27
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
28
StackLayout {
44
29
id: settingsStack
45
- currentIndex: 0
30
+ currentIndex: onboarding ? 0 : snapshotLoaded ? 2 : snapshotVerified ? 2 : snapshotLoading ? 1 : 0
46
31
47
32
ColumnLayout {
48
33
Layout .alignment : Qt .AlignHCenter
@@ -69,6 +54,19 @@ ColumnLayout {
69
54
" It will be automatically verified in the background." )
70
55
}
71
56
57
+ CoreText {
58
+ Layout .fillWidth : true
59
+ Layout .topMargin : 20
60
+ color: Theme .color .neutral6
61
+ font .pixelSize : 17
62
+ visible: ! headersSynced
63
+ text: ! headersSynced
64
+ ? qsTr (" Please wait for headers to sync before loading a snapshot." )
65
+ : qsTr (" " )
66
+ wrap: true
67
+ wrapMode: Text .WordWrap
68
+ }
69
+
72
70
ContinueButton {
73
71
Layout .preferredWidth : Math .min (300 , columnLayout .width - 2 * Layout .leftMargin )
74
72
Layout .topMargin : 40
@@ -77,11 +75,23 @@ ColumnLayout {
77
75
Layout .bottomMargin : 20
78
76
Layout .alignment : Qt .AlignCenter
79
77
text: qsTr (" Choose snapshot file" )
80
- onClicked: {
81
- settingsStack .currentIndex = 1
82
- snapshotSimulationTimer .start ()
78
+ enabled: headersSynced
79
+ onClicked: fileDialog .open ()
80
+ }
81
+
82
+ FileDialog {
83
+ id: fileDialog
84
+ folder: shortcuts .home
85
+ selectMultiple: false
86
+ selectExisting: true
87
+ nameFilters: [" Snapshot files (*.dat)" , " All files (*)" ]
88
+ onAccepted: {
89
+ selectedFile = fileUrl .toString ()
90
+ snapshotFileName = selectedFile
91
+ nodeModel .snapshotLoadThread (snapshotFileName)
83
92
}
84
93
}
94
+ // TODO: Handle file error signal
85
95
}
86
96
87
97
ColumnLayout {
@@ -102,14 +112,15 @@ ColumnLayout {
102
112
Layout .leftMargin : 20
103
113
Layout .rightMargin : 20
104
114
header: qsTr (" Loading Snapshot" )
115
+ description: qsTr (" This might take a while..." )
105
116
}
106
117
107
118
ProgressIndicator {
108
119
id: progressIndicator
109
120
Layout .topMargin : 20
110
121
width: 200
111
122
height: 20
112
- progress: snapshotVerificationProgress
123
+ progress: nodeModel . snapshotProgress
113
124
Layout .alignment : Qt .AlignCenter
114
125
progressColor: Theme .color .blue
115
126
}
@@ -137,8 +148,10 @@ ColumnLayout {
137
148
descriptionColor: Theme .color .neutral6
138
149
descriptionSize: 17
139
150
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." )
151
+ description: snapshotInfo && snapshotInfo[" date" ] ?
152
+ qsTr (" It contains unspent transactions up to %1. Next, transactions will be verified and newer transactions downloaded." ).arg (snapshotInfo[" date" ]) :
153
+ qsTr (" It contains transactions up to DEBUG. Newer transactions still need to be downloaded." +
154
+ " The data will be verified in the background." )
142
155
}
143
156
144
157
ContinueButton {
@@ -147,9 +160,8 @@ ColumnLayout {
147
160
Layout .alignment : Qt .AlignCenter
148
161
text: qsTr (" Done" )
149
162
onClicked: {
150
- snapshotImportCompleted ()
151
- connectionSwipe .decrementCurrentIndex ()
152
- connectionSwipe .decrementCurrentIndex ()
163
+ chainModel .isSnapshotActiveChanged ()
164
+ back ()
153
165
}
154
166
}
155
167
@@ -188,15 +200,28 @@ ColumnLayout {
188
200
font .pixelSize : 14
189
201
}
190
202
CoreText {
191
- text: qsTr (" 200,000" )
203
+ text: snapshotInfo && snapshotInfo[" height" ] ?
204
+ snapshotInfo[" height" ] : qsTr (" DEBUG" )
192
205
Layout .alignment : Qt .AlignRight
193
206
font .pixelSize : 14
194
207
}
195
208
}
196
209
Separator { Layout .fillWidth : true }
197
- CoreText {
198
- text: qsTr (" Hash: 0x1234567890abcdef..." )
199
- font .pixelSize : 14
210
+ ColumnLayout {
211
+ Layout .fillWidth : true
212
+ spacing: 5
213
+ CoreText {
214
+ text: qsTr (" Hash:" )
215
+ font .pixelSize : 14
216
+ }
217
+ CoreText {
218
+ text: snapshotInfo && snapshotInfo[" hashSerializedFirstHalf" ] ?
219
+ snapshotInfo[" hashSerializedFirstHalf" ] + " \n " + snapshotInfo[" hashSerializedSecondHalf" ] :
220
+ qsTr (" DEBUG" )
221
+ Layout .fillWidth : true
222
+ font .pixelSize : 14
223
+ textFormat: Text .PlainText
224
+ }
200
225
}
201
226
}
202
227
}
0 commit comments