From e35e4b2ba052c9a533626286026dbe0a2d546c5b Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 12 Nov 2019 13:23:09 +0200 Subject: util: Add PruneMiBtoGB() function Now the text of prune QCheckBox shows the space in GB instead of thousands MiB, which is consistent with other parts of the GUI. --- src/qt/intro.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/qt/intro.cpp') diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp index f064556ae5..183c2fcfb6 100644 --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -23,7 +24,7 @@ #include /* Total required space (in GB) depending on user choice (prune, not prune) */ -static uint64_t requiredSpace; +static int64_t requiredSpace; /* Check free space asynchronously to prevent hanging the UI thread. @@ -130,18 +131,18 @@ Intro::Intro(QWidget *parent, uint64_t blockchain_size, uint64_t chain_state_siz ); ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME)); - uint64_t pruneTarget = std::max(0, gArgs.GetArg("-prune", 0)); - if (pruneTarget > 1) { // -prune=1 means enabled, above that it's a size in MB + int64_t prune_target_mib = std::max(0, gArgs.GetArg("-prune", 0)); + if (prune_target_mib > 1) { // -prune=1 means enabled, above that it's a size in MiB ui->prune->setChecked(true); ui->prune->setEnabled(false); } - ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(pruneTarget ? pruneTarget / 1000 : DEFAULT_PRUNE_TARGET_GB)); + const int prune_target_gb = PruneMiBtoGB(prune_target_mib); + ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(prune_target_gb ? prune_target_gb : DEFAULT_PRUNE_TARGET_GB)); requiredSpace = m_blockchain_size; QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time."); - if (pruneTarget) { - uint64_t prunedGBs = std::ceil(pruneTarget * 1024 * 1024.0 / GB_BYTES); - if (prunedGBs <= requiredSpace) { - requiredSpace = prunedGBs; + if (prune_target_gb) { + if (prune_target_gb <= requiredSpace) { + requiredSpace = prune_target_gb; storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory."); } ui->lblExplanation3->setVisible(true); -- cgit v1.2.3