@@ -10,6 +10,7 @@ import Qt.labs.settings 1.0
1010import org.bitcoincore.qt 1.0
1111
1212import "../controls"
13+ import "../controls/utils.js" as Utils
1314
1415Item {
1516 id: root
2829 property bool synced: nodeModel .verificationProgress > 0.999
2930 property string syncProgress: formatProgressPercentage (nodeModel .verificationProgress * 100 )
3031 property bool paused: false
31- property var syncState: formatRemainingSyncTime (nodeModel .remainingSyncTime )
32+ property var syncState: Utils . formatRemainingSyncTime (nodeModel .remainingSyncTime )
3233 property string syncTime: syncState .text
3334 property bool estimating: syncState .estimating
3435
@@ -234,65 +235,4 @@ Item {
234235 return " 0%"
235236 }
236237 }
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- }
298238}
0 commit comments