mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
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).
This commit is contained in:
@@ -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) + " " +
|
||||
|
||||
Reference in New Issue
Block a user