@@ -107,14 +107,24 @@ void FreespaceChecker::check()
107107 Q_EMIT reply (replyStatus, replyMessage, freeBytesAvailable);
108108}
109109
110+ namespace {
111+ // ! Return pruning size that will be used if automatic pruning is enabled.
112+ int GetPruneTargetGB ()
113+ {
114+ int64_t prune_target_mib = gArgs .GetArg (" -prune" , 0 );
115+ // >1 means automatic pruning is enabled by config, 1 means manual pruning, 0 means no pruning.
116+ return prune_target_mib > 1 ? PruneMiBtoGB (prune_target_mib) : DEFAULT_PRUNE_TARGET_GB;
117+ }
118+ } // namespace
110119
111120Intro::Intro (QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_size_gb) :
112121 QDialog(parent),
113122 ui(new Ui::Intro),
114123 thread(nullptr ),
115124 signalled(false ),
116125 m_blockchain_size_gb(blockchain_size_gb),
117- m_chain_state_size_gb(chain_state_size_gb)
126+ m_chain_state_size_gb(chain_state_size_gb),
127+ m_prune_target_gb{GetPruneTargetGB ()}
118128{
119129 ui->setupUi (this );
120130 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
128138 );
129139 ui->lblExplanation2 ->setText (ui->lblExplanation2 ->text ().arg (PACKAGE_NAME));
130140
131- int64_t prune_target_mib = std::max<int64_t >(0 , gArgs .GetArg (" -prune" , 0 ));
132- if (prune_target_mib > 1 ) { // -prune=1 means enabled, above that it's a size in MiB
141+ if (gArgs .GetArg (" -prune" , 0 ) > 1 ) { // -prune=1 means enabled, above that it's a size in MiB
133142 ui->prune ->setChecked (true );
134143 ui->prune ->setEnabled (false );
135144 }
136- const int prune_target_gb = PruneMiBtoGB (prune_target_mib);
137- 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));
138- UpdatePruneLabels (prune_target_gb);
145+ ui->prune ->setText (tr (" Discard blocks after verification, except most recent %1 GB (prune)" ).arg (m_prune_target_gb));
146+ UpdatePruneLabels (ui->prune ->isChecked ());
147+
148+ connect (ui->prune , &QCheckBox::toggled, [this ](bool prune_checked) {
149+ UpdatePruneLabels (prune_checked);
150+ UpdateFreeSpaceLabel ();
151+ });
152+
139153 startThread ();
140154}
141155
@@ -337,15 +351,15 @@ QString Intro::getPathToCheck()
337351 return retval;
338352}
339353
340- void Intro::UpdatePruneLabels (int64_t prune_target_gb )
354+ void Intro::UpdatePruneLabels (bool prune_checked )
341355{
342356 m_required_space_gb = m_blockchain_size_gb + m_chain_state_size_gb;
343357 QString storageRequiresMsg = tr (" At least %1 GB of data will be stored in this directory, and it will grow over time." );
344- if (0 < prune_target_gb && prune_target_gb <= m_blockchain_size_gb) {
345- m_required_space_gb = prune_target_gb + m_chain_state_size_gb;
358+ if (prune_checked && m_prune_target_gb <= m_blockchain_size_gb) {
359+ m_required_space_gb = m_prune_target_gb + m_chain_state_size_gb;
346360 storageRequiresMsg = tr (" Approximately %1 GB of data will be stored in this directory." );
347361 }
348- ui->lblExplanation3 ->setVisible (prune_target_gb > 0 );
362+ ui->lblExplanation3 ->setVisible (prune_checked );
349363 ui->sizeWarningLabel ->setText (
350364 tr (" %1 will download and store a copy of the Bitcoin block chain." ).arg (PACKAGE_NAME) + " " +
351365 storageRequiresMsg.arg (m_required_space_gb) + " " +
0 commit comments