55import  QtQuick  2.15 
66import  QtQuick.Controls  2.15 
77import  QtQuick.Layouts  1.15 
8+ import  QtQuick.Dialogs  1.3 
89
910import  "../controls" 
1011
@@ -18,7 +19,7 @@ ColumnLayout {
1819    width:  Math .min (parent .width , 450 )
1920    anchors .horizontalCenter :  parent .horizontalCenter 
2021
21- 
22+      //  TODO: Remove this once the verification progress is available 
2223    Timer {
2324        id:  snapshotSimulationTimer
2425        interval:  50  //  Update every 50ms
@@ -29,7 +30,7 @@ ColumnLayout {
2930                snapshotVerificationProgress +=  0.01 
3031            } else  {
3132                snapshotVerificationCycles++ 
32-                 if  (snapshotVerificationCycles <  1 ) {
33+                 if  (snapshotVerificationCycles <  3 ) {
3334                    snapshotVerificationProgress =  0 
3435                } else  {
3536                    running =  false 
@@ -42,7 +43,7 @@ ColumnLayout {
4243
4344    StackLayout {
4445        id:  settingsStack
45-         currentIndex:  0 
46+         currentIndex:  snapshotVerified  ?   2   :   0 
4647
4748        ColumnLayout {
4849            Layout .alignment :  Qt .AlignHCenter 
@@ -78,8 +79,24 @@ ColumnLayout {
7879                Layout .alignment :  Qt .AlignCenter 
7980                text:  qsTr (" Choose snapshot file" 
8081                onClicked:  {
81-                     settingsStack .currentIndex  =  1 
82-                     snapshotSimulationTimer .start ()
82+                     fileDialog .open ()
83+                 }
84+             }
85+ 
86+             FileDialog {
87+                 id:  fileDialog
88+                 folder:  shortcuts .home 
89+                 selectMultiple:  false 
90+                 onAccepted:  {
91+                     console .log (" File chosen:" fileDialog .fileUrls )
92+                     var  snapshotFileName =  fileDialog .fileUrl .toString ()
93+                     console .log (" Snapshot file name:" 
94+                     if  (snapshotFileName .endsWith (" .dat" 
95+                         //  optionsModel.setSnapshotDirectory(snapshotFileName)
96+                         //  console.log("Snapshot directory set:", optionsModel.getSnapshotDirectory())
97+                         nodeModel .initializeSnapshot (true , snapshotFileName)
98+                         settingsStack .currentIndex  =  1 
99+                     }
83100                }
84101            }
85102        }
@@ -109,10 +126,29 @@ ColumnLayout {
109126                Layout .topMargin :  20 
110127                width:  200 
111128                height:  20 
112-                 progress:  snapshotVerificationProgress
129+                 //  TODO: uncomment this once the verification progress is available
130+                 //  progress: nodeModel.verificationProgress
131+                 progress:  0 
113132                Layout .alignment :  Qt .AlignCenter 
114133                progressColor:  Theme .color .blue 
115134            }
135+ 
136+             Connections {
137+                 target:  nodeModel
138+                 //  TODO: uncomment this once the verification progress is available
139+                 //  function onVerificationProgressChanged() {
140+                 //      progressIndicator.progress = nodeModel.verificationProgress
141+                 //  }
142+                 function  onSnapshotLoaded (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+                     }
150+                 }
151+             }
116152        }
117153
118154        ColumnLayout {
@@ -137,6 +173,7 @@ ColumnLayout {
137173                descriptionColor:  Theme .color .neutral6 
138174                descriptionSize:  17 
139175                descriptionLineHeight:  1.1 
176+                 //  TODO: Update this description once the snapshot is verified
140177                description:  qsTr (" It contains transactions up to January 12, 2024. Newer transactions still need to be downloaded." + 
141178                "  The data will be verified in the background." 
142179            }
@@ -153,6 +190,9 @@ ColumnLayout {
153190                }
154191            }
155192
193+             //  TODO: Update this with the actual snapshot details
194+             //  TODO: uncomment this once the snapshot details are available
195+             /* 
156196            Setting { 
157197                id: viewDetails 
158198                Layout.alignment: Qt.AlignCenter 
@@ -188,17 +228,20 @@ ColumnLayout {
188228                        font.pixelSize: 14 
189229                    } 
190230                    CoreText { 
231+                         // TODO: Update this with the actual block height 
191232                        text: qsTr("200,000") 
192233                        Layout.alignment: Qt.AlignRight 
193234                        font.pixelSize: 14 
194235                    } 
195236                } 
196237                Separator { Layout.fillWidth: true } 
197238                CoreText { 
239+                     // TODO: Update this with the actual snapshot file hash 
198240                    text: qsTr("Hash: 0x1234567890abcdef...") 
199241                    font.pixelSize: 14 
200242                } 
201243            } 
244+             */  
202245        }
203246    }
204247}
0 commit comments