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: 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
+
18
24
width: Math .min (parent .width , 450 )
19
25
anchors .horizontalCenter : parent .horizontalCenter
20
26
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
27
StackLayout {
44
28
id: settingsStack
45
- currentIndex: 0
29
+ currentIndex: onboarding ? 0 : snapshotLoaded ? 2 : snapshotVerified ? 2 : snapshotLoading ? 1 : 0
46
30
47
31
ColumnLayout {
48
32
Layout .alignment : Qt .AlignHCenter
@@ -77,11 +61,22 @@ ColumnLayout {
77
61
Layout .bottomMargin : 20
78
62
Layout .alignment : Qt .AlignCenter
79
63
text: qsTr (" Choose snapshot file" )
80
- onClicked: {
81
- settingsStack .currentIndex = 1
82
- snapshotSimulationTimer .start ()
64
+ onClicked: fileDialog .open ()
65
+ }
66
+
67
+ FileDialog {
68
+ id: fileDialog
69
+ folder: shortcuts .home
70
+ selectMultiple: false
71
+ selectExisting: true
72
+ nameFilters: [" Snapshot files (*.dat)" , " All files (*)" ]
73
+ onAccepted: {
74
+ selectedFile = fileUrl .toString ()
75
+ snapshotFileName = selectedFile
76
+ nodeModel .snapshotLoadThread (snapshotFileName)
83
77
}
84
78
}
79
+ // TODO: Handle file error signal
85
80
}
86
81
87
82
ColumnLayout {
@@ -102,14 +97,15 @@ ColumnLayout {
102
97
Layout .leftMargin : 20
103
98
Layout .rightMargin : 20
104
99
header: qsTr (" Loading Snapshot" )
100
+ description: qsTr (" This might take a while..." )
105
101
}
106
102
107
103
ProgressIndicator {
108
104
id: progressIndicator
109
105
Layout .topMargin : 20
110
106
width: 200
111
107
height: 20
112
- progress: snapshotVerificationProgress
108
+ progress: nodeModel . snapshotProgress
113
109
Layout .alignment : Qt .AlignCenter
114
110
progressColor: Theme .color .blue
115
111
}
@@ -137,8 +133,11 @@ ColumnLayout {
137
133
descriptionColor: Theme .color .neutral6
138
134
descriptionSize: 17
139
135
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." )
136
+ description: snapshotInfo && snapshotInfo[" date" ] ?
137
+ qsTr (" It contains transactions up to %1. Newer transactions still need to be downloaded." +
138
+ " The data will be verified in the background." ).arg (snapshotInfo[" date" ]) :
139
+ qsTr (" It contains transactions up to DEBUG. Newer transactions still need to be downloaded." +
140
+ " The data will be verified in the background." )
142
141
}
143
142
144
143
ContinueButton {
@@ -147,9 +146,8 @@ ColumnLayout {
147
146
Layout .alignment : Qt .AlignCenter
148
147
text: qsTr (" Done" )
149
148
onClicked: {
150
- snapshotImportCompleted ()
151
- connectionSwipe .decrementCurrentIndex ()
152
- connectionSwipe .decrementCurrentIndex ()
149
+ chainModel .isSnapshotActiveChanged ()
150
+ back ()
153
151
}
154
152
}
155
153
@@ -188,14 +186,17 @@ ColumnLayout {
188
186
font .pixelSize : 14
189
187
}
190
188
CoreText {
191
- text: qsTr (" 200,000" )
189
+ text: snapshotInfo && snapshotInfo[" height" ] ?
190
+ snapshotInfo[" height" ] : qsTr (" DEBUG" )
192
191
Layout .alignment : Qt .AlignRight
193
192
font .pixelSize : 14
194
193
}
195
194
}
196
195
Separator { Layout .fillWidth : true }
197
196
CoreText {
198
- text: qsTr (" Hash: 0x1234567890abcdef..." )
197
+ text: snapshotInfo && snapshotInfo[" hashSerialized" ] ?
198
+ qsTr (" Hash: %1" ).arg (snapshotInfo[" hashSerialized" ].substring (0 , 13 ) + " ..." ) :
199
+ qsTr (" Hash: DEBUG" )
199
200
font .pixelSize : 14
200
201
}
201
202
}
0 commit comments