GUI/Intro: Rework UI flow to let the user set prune size in GBs

pull/826/head
Luke Dashjr 5 years ago
parent f2e5a6b54f
commit e2dcd957fa

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>674</width>
<height>415</height>
<height>447</height>
</rect>
</property>
<property name="windowTitle">
@ -200,6 +200,40 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="pruneOptLayout">
<item>
<widget class="QCheckBox" name="prune">
<property name="text">
<string>Limit block chain storage to</string>
</property>
<property name="toolTip">
<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>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="pruneGB">
<property name="suffix">
<string> GB</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="lblExplanation1">
<property name="text">
@ -210,16 +244,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="prune">
<property name="toolTip">
<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>
</property>
<property name="text">
<string></string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblExplanation2">
<property name="text">

@ -17,6 +17,7 @@
#include <interfaces/node.h>
#include <util/system.h>
#include <validation.h>
#include <QFileDialog>
#include <QSettings>
@ -139,17 +140,25 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
);
ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME));
const int min_prune_target_GB = std::ceil(MIN_DISK_SPACE_FOR_BLOCK_FILES / 1e9);
ui->pruneGB->setRange(min_prune_target_GB, std::numeric_limits<int>::max());
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);
}
ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(m_prune_target_gb));
ui->pruneGB->setValue(m_prune_target_gb);
ui->pruneGB->setToolTip(ui->prune->toolTip());
UpdatePruneLabels(ui->prune->isChecked());
connect(ui->prune, &QCheckBox::toggled, [this](bool prune_checked) {
UpdatePruneLabels(prune_checked);
UpdateFreeSpaceLabel();
});
connect(ui->pruneGB, QOverload<int>::of(&QSpinBox::valueChanged), [this](int prune_GB) {
m_prune_target_gb = prune_GB;
UpdatePruneLabels(ui->prune->isChecked());
UpdateFreeSpaceLabel();
});
startThread();
}
@ -371,6 +380,7 @@ void Intro::UpdatePruneLabels(bool prune_checked)
storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory.");
}
ui->lblExplanation3->setVisible(prune_checked);
ui->pruneGB->setEnabled(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) + " " +

@ -73,7 +73,7 @@ private:
//! Total required space (in GB) depending on user choice (prune or not prune).
int64_t m_required_space_gb{0};
uint64_t m_bytes_available{0};
const int64_t m_prune_target_gb;
int64_t m_prune_target_gb;
void startThread();
void checkPath(const QString &dataDir);

Loading…
Cancel
Save