@@ -107,14 +107,24 @@ void FreespaceChecker::check()
107
107
Q_EMIT reply (replyStatus, replyMessage, freeBytesAvailable);
108
108
}
109
109
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
110
119
111
120
Intro::Intro (QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_size_gb) :
112
121
QDialog(parent),
113
122
ui(new Ui::Intro),
114
123
thread(nullptr ),
115
124
signalled(false ),
116
125
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 ()}
118
128
{
119
129
ui->setupUi (this );
120
130
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
128
138
);
129
139
ui->lblExplanation2 ->setText (ui->lblExplanation2 ->text ().arg (PACKAGE_NAME));
130
140
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
133
142
ui->prune ->setChecked (true );
134
143
ui->prune ->setEnabled (false );
135
144
}
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
+
139
153
startThread ();
140
154
}
141
155
@@ -337,15 +351,15 @@ QString Intro::getPathToCheck()
337
351
return retval;
338
352
}
339
353
340
- void Intro::UpdatePruneLabels (int64_t prune_target_gb )
354
+ void Intro::UpdatePruneLabels (bool prune_checked )
341
355
{
342
356
m_required_space_gb = m_blockchain_size_gb + m_chain_state_size_gb;
343
357
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;
346
360
storageRequiresMsg = tr (" Approximately %1 GB of data will be stored in this directory." );
347
361
}
348
- ui->lblExplanation3 ->setVisible (prune_target_gb > 0 );
362
+ ui->lblExplanation3 ->setVisible (prune_checked );
349
363
ui->sizeWarningLabel ->setText (
350
364
tr (" %1 will download and store a copy of the Bitcoin block chain." ).arg (PACKAGE_NAME) + " " +
351
365
storageRequiresMsg.arg (m_required_space_gb) + " " +
0 commit comments