aboutsummaryrefslogtreecommitdiff
path: root/src/qt/intro.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2019-12-08 23:28:50 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-01-14 19:14:14 +0200
commit4f7127d1e3a51f0f55d42a08439c516dcc8d1a26 (patch)
tree47da20e9c1cc77f8d3d287f6b270bb255c516df3 /src/qt/intro.cpp
parent4824a7d36cf47e766865e0fefe952ec860eb82dd (diff)
downloadbitcoin-4f7127d1e3a51f0f55d42a08439c516dcc8d1a26.tar.xz
gui: Make Intro consistent with prune checkbox
When prune checkbox is toggled, the related text labels and the amount of required space shown are updated (previously they were only updated when the data directory was updated).
Diffstat (limited to 'src/qt/intro.cpp')
-rw-r--r--src/qt/intro.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp
index cb7b13260a..873d9dcd6f 100644
--- a/src/qt/intro.cpp
+++ b/src/qt/intro.cpp
@@ -107,6 +107,15 @@ void FreespaceChecker::check()
Q_EMIT reply(replyStatus, replyMessage, freeBytesAvailable);
}
+namespace {
+//! Return pruning size that will be used if automatic pruning is enabled.
+int GetPruneTargetGB()
+{
+ int64_t prune_target_mib = gArgs.GetArg("-prune", 0);
+ // >1 means automatic pruning is enabled by config, 1 means manual pruning, 0 means no pruning.
+ return prune_target_mib > 1 ? PruneMiBtoGB(prune_target_mib) : DEFAULT_PRUNE_TARGET_GB;
+}
+} // namespace
Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_size_gb) :
QDialog(parent),
@@ -114,7 +123,8 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
thread(nullptr),
signalled(false),
m_blockchain_size_gb(blockchain_size_gb),
- m_chain_state_size_gb(chain_state_size_gb)
+ m_chain_state_size_gb(chain_state_size_gb),
+ m_prune_target_gb{GetPruneTargetGB()}
{
ui->setupUi(this);
ui->welcomeLabel->setText(ui->welcomeLabel->text().arg(PACKAGE_NAME));
@@ -128,14 +138,18 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
);
ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME));
- int64_t prune_target_mib = std::max<int64_t>(0, gArgs.GetArg("-prune", 0));
- if (prune_target_mib > 1) { // -prune=1 means enabled, above that it's a size in MiB
+ if (gArgs.GetArg("-prune", 0) > 1) { // -prune=1 means enabled, above that it's a size in MiB
ui->prune->setChecked(true);
ui->prune->setEnabled(false);
}
- 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));
- UpdatePruneLabels(prune_target_gb);
+ ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(m_prune_target_gb));
+ UpdatePruneLabels(ui->prune->isChecked());
+
+ connect(ui->prune, &QCheckBox::toggled, [this](bool prune_checked) {
+ UpdatePruneLabels(prune_checked);
+ UpdateFreeSpaceLabel();
+ });
+
startThread();
}
@@ -337,15 +351,15 @@ QString Intro::getPathToCheck()
return retval;
}
-void Intro::UpdatePruneLabels(int64_t prune_target_gb)
+void Intro::UpdatePruneLabels(bool prune_checked)
{
m_required_space_gb = m_blockchain_size_gb + m_chain_state_size_gb;
QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time.");
- if (0 < prune_target_gb && prune_target_gb <= m_blockchain_size_gb) {
- m_required_space_gb = prune_target_gb + m_chain_state_size_gb;
+ if (prune_checked && m_prune_target_gb <= m_blockchain_size_gb) {
+ m_required_space_gb = m_prune_target_gb + m_chain_state_size_gb;
storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory.");
}
- ui->lblExplanation3->setVisible(prune_target_gb > 0);
+ ui->lblExplanation3->setVisible(prune_checked);
ui->sizeWarningLabel->setText(
tr("%1 will download and store a copy of the Bitcoin block chain.").arg(PACKAGE_NAME) + " " +
storageRequiresMsg.arg(m_required_space_gb) + " " +