From 603d8b85aabbf604d0d83c084d577efd9937895d Mon Sep 17 00:00:00 2001 From: jarolrod Date: Tue, 28 Feb 2023 02:10:58 -0500 Subject: [PATCH] qml: format BlockClock progress percentage according to the design file --- src/qml/components/BlockClock.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qml/components/BlockClock.qml b/src/qml/components/BlockClock.qml index 389eefd6fb..fe80e76818 100644 --- a/src/qml/components/BlockClock.qml +++ b/src/qml/components/BlockClock.qml @@ -88,7 +88,7 @@ Item { name: "IBD"; when: !synced && !paused && connected PropertyChanges { target: root - header: Math.round(nodeModel.verificationProgress * 100) + "%" + header: formatProgressPercentage(nodeModel.verificationProgress * 100) subText: formatRemainingSyncTime(nodeModel.remainingSyncTime) } }, @@ -139,6 +139,18 @@ Item { } ] + function formatProgressPercentage(progress) { + if (progress >= 1) { + return Math.round(progress) + "%" + } else if (progress >= 0.1) { + return progress.toFixed(1) + "%" + } else if (progress >= 0.01) { + return progress.toFixed(2) + "%" + } else { + return "0%" + } + } + function formatRemainingSyncTime(milliseconds) { var minutes = Math.floor(milliseconds / 60000); var seconds = Math.floor((milliseconds % 60000) / 1000);