@@ -10,6 +10,7 @@ import Qt.labs.settings 1.0
10
10
import org.bitcoincore.qt 1.0
11
11
12
12
import "../controls"
13
+ import "../controls/utils.js" as Utils
13
14
14
15
Item {
15
16
id: root
28
29
property bool synced: nodeModel .verificationProgress > 0.999
29
30
property string syncProgress: formatProgressPercentage (nodeModel .verificationProgress * 100 )
30
31
property bool paused: false
31
- property var syncState: formatRemainingSyncTime (nodeModel .remainingSyncTime )
32
+ property var syncState: Utils . formatRemainingSyncTime (nodeModel .remainingSyncTime )
32
33
property string syncTime: syncState .text
33
34
property bool estimating: syncState .estimating
34
35
@@ -234,65 +235,4 @@ Item {
234
235
return " 0%"
235
236
}
236
237
}
237
-
238
- function formatRemainingSyncTime (milliseconds ) {
239
- var minutes = Math .floor (milliseconds / 60000 );
240
- var seconds = Math .floor ((milliseconds % 60000 ) / 1000 );
241
- var weeks = Math .floor (minutes / 10080 );
242
- minutes %= 10080 ;
243
- var days = Math .floor (minutes / 1440 );
244
- minutes %= 1440 ;
245
- var hours = Math .floor (minutes / 60 );
246
- minutes %= 60 ;
247
- var result = " " ;
248
- var estimatingStatus = false ;
249
-
250
- if (weeks > 0 ) {
251
- return {
252
- text: " ~" + weeks + (weeks === 1 ? " week" : " weeks" ) + " left" ,
253
- estimating: false
254
- };
255
- }
256
- if (days > 0 ) {
257
- return {
258
- text: " ~" + days + (days === 1 ? " day" : " days" ) + " left" ,
259
- estimating: false
260
- };
261
- }
262
- if (hours >= 5 ) {
263
- return {
264
- text: " ~" + hours + (hours === 1 ? " hour" : " hours" ) + " left" ,
265
- estimating: false
266
- };
267
- }
268
- if (hours > 0 ) {
269
- return {
270
- text: " ~" + hours + " h " + minutes + " m" + " left" ,
271
- estimating: false
272
- };
273
- }
274
- if (minutes >= 5 ) {
275
- return {
276
- text: " ~" + minutes + (minutes === 1 ? " minute" : " minutes" ) + " left" ,
277
- estimating: false
278
- };
279
- }
280
- if (minutes > 0 ) {
281
- return {
282
- text: " ~" + minutes + " m " + seconds + " s" + " left" ,
283
- estimating: false
284
- };
285
- }
286
- if (seconds > 0 ) {
287
- return {
288
- text: " ~" + seconds + (seconds === 1 ? " second" : " seconds" ) + " left" ,
289
- estimating: false
290
- };
291
- } else {
292
- return {
293
- text: " Estimating" ,
294
- estimating: true
295
- };
296
- }
297
- }
298
238
}
0 commit comments