[gui] intro: add prune preference

Adds a checkbox to the introduction screen letting the user enable pruning from the start.
Disable checkbox when launched with -prune
This commit is contained in:
Sjors Provoost
2019-08-24 19:13:04 +02:00
parent 1bbc49d207
commit c8de347a9d
4 changed files with 28 additions and 3 deletions

View File

@@ -131,6 +131,11 @@ Intro::Intro(QWidget *parent, uint64_t blockchain_size, uint64_t chain_state_siz
ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME));
uint64_t pruneTarget = std::max<int64_t>(0, gArgs.GetArg("-prune", 0));
if (pruneTarget > 1) { // -prune=1 means enabled, above that it's a size in MB
ui->prune->setChecked(true);
ui->prune->setEnabled(false);
}
ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(pruneTarget ? pruneTarget / 1000 : 2));
requiredSpace = m_blockchain_size;
QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time.");
if (pruneTarget) {
@@ -180,7 +185,7 @@ void Intro::setDataDirectory(const QString &dataDir)
}
}
bool Intro::showIfNeeded(interfaces::Node& node, bool& did_show_intro)
bool Intro::showIfNeeded(interfaces::Node& node, bool& did_show_intro, bool& prune)
{
did_show_intro = false;
@@ -230,6 +235,9 @@ bool Intro::showIfNeeded(interfaces::Node& node, bool& did_show_intro)
}
}
// Additional preferences:
prune = intro.ui->prune->isChecked();
settings.setValue("strDataDir", dataDir);
settings.setValue("fReset", false);
}