Skip to content

Commit e2dcd95

Browse files
committed
GUI/Intro: Rework UI flow to let the user set prune size in GBs
1 parent f2e5a6b commit e2dcd95

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

src/qt/forms/intro.ui

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>674</width>
10-
<height>415</height>
10+
<height>447</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -200,6 +200,40 @@
200200
</item>
201201
</layout>
202202
</item>
203+
<item>
204+
<layout class="QHBoxLayout" name="pruneOptLayout">
205+
<item>
206+
<widget class="QCheckBox" name="prune">
207+
<property name="text">
208+
<string>Limit block chain storage to</string>
209+
</property>
210+
<property name="toolTip">
211+
<string>Reverting this setting requires re-downloading the entire blockchain. It is faster to download the full chain first and prune it later. Disables some advanced features.</string>
212+
</property>
213+
</widget>
214+
</item>
215+
<item>
216+
<widget class="QSpinBox" name="pruneGB">
217+
<property name="suffix">
218+
<string> GB</string>
219+
</property>
220+
</widget>
221+
</item>
222+
<item>
223+
<spacer name="horizontalSpacer_2">
224+
<property name="orientation">
225+
<enum>Qt::Horizontal</enum>
226+
</property>
227+
<property name="sizeHint" stdset="0">
228+
<size>
229+
<width>40</width>
230+
<height>20</height>
231+
</size>
232+
</property>
233+
</spacer>
234+
</item>
235+
</layout>
236+
</item>
203237
<item>
204238
<widget class="QLabel" name="lblExplanation1">
205239
<property name="text">
@@ -210,16 +244,6 @@
210244
</property>
211245
</widget>
212246
</item>
213-
<item>
214-
<widget class="QCheckBox" name="prune">
215-
<property name="toolTip">
216-
<string>Reverting this setting requires re-downloading the entire blockchain. It is faster to download the full chain first and prune it later. Disables some advanced features.</string>
217-
</property>
218-
<property name="text">
219-
<string></string>
220-
</property>
221-
</widget>
222-
</item>
223247
<item>
224248
<widget class="QLabel" name="lblExplanation2">
225249
<property name="text">

src/qt/intro.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <interfaces/node.h>
1919
#include <util/system.h>
20+
#include <validation.h>
2021

2122
#include <QFileDialog>
2223
#include <QSettings>
@@ -139,17 +140,25 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
139140
);
140141
ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME));
141142

143+
const int min_prune_target_GB = std::ceil(MIN_DISK_SPACE_FOR_BLOCK_FILES / 1e9);
144+
ui->pruneGB->setRange(min_prune_target_GB, std::numeric_limits<int>::max());
142145
if (gArgs.GetArg("-prune", 0) > 1) { // -prune=1 means enabled, above that it's a size in MiB
143146
ui->prune->setChecked(true);
144147
ui->prune->setEnabled(false);
145148
}
146-
ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(m_prune_target_gb));
149+
ui->pruneGB->setValue(m_prune_target_gb);
150+
ui->pruneGB->setToolTip(ui->prune->toolTip());
147151
UpdatePruneLabels(ui->prune->isChecked());
148152

149153
connect(ui->prune, &QCheckBox::toggled, [this](bool prune_checked) {
150154
UpdatePruneLabels(prune_checked);
151155
UpdateFreeSpaceLabel();
152156
});
157+
connect(ui->pruneGB, QOverload<int>::of(&QSpinBox::valueChanged), [this](int prune_GB) {
158+
m_prune_target_gb = prune_GB;
159+
UpdatePruneLabels(ui->prune->isChecked());
160+
UpdateFreeSpaceLabel();
161+
});
153162

154163
startThread();
155164
}
@@ -371,6 +380,7 @@ void Intro::UpdatePruneLabels(bool prune_checked)
371380
storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory.");
372381
}
373382
ui->lblExplanation3->setVisible(prune_checked);
383+
ui->pruneGB->setEnabled(prune_checked);
374384
ui->sizeWarningLabel->setText(
375385
tr("%1 will download and store a copy of the Bitcoin block chain.").arg(PACKAGE_NAME) + " " +
376386
storageRequiresMsg.arg(m_required_space_gb) + " " +

src/qt/intro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private Q_SLOTS:
7373
//! Total required space (in GB) depending on user choice (prune or not prune).
7474
int64_t m_required_space_gb{0};
7575
uint64_t m_bytes_available{0};
76-
const int64_t m_prune_target_gb;
76+
int64_t m_prune_target_gb;
7777

7878
void startThread();
7979
void checkPath(const QString &dataDir);

0 commit comments

Comments
 (0)