diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -612,8 +612,10 @@ /// 5. Now that settings and translations are available, ask user for data /// directory. User language is set up: pick a data directory. bool did_show_intro = false; + // Intro dialog prune check box + bool prune = false; // Gracefully exit if the user cancels - if (!Intro::showIfNeeded(*node, did_show_intro)) { + if (!Intro::showIfNeeded(*node, did_show_intro, prune)) { return EXIT_SUCCESS; } @@ -712,6 +714,11 @@ // Load GUI settings from QSettings app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false)); + if (did_show_intro) { + // Store intro dialog settings other than datadir (network specific) + app.SetPrune(prune, true); + } + // Get global config Config &config = const_cast(GetConfig()); diff --git a/src/qt/forms/intro.ui b/src/qt/forms/intro.ui --- a/src/qt/forms/intro.ui +++ b/src/qt/forms/intro.ui @@ -210,6 +210,16 @@ + + + + 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. + + + + + + diff --git a/src/qt/intro.h b/src/qt/intro.h --- a/src/qt/intro.h +++ b/src/qt/intro.h @@ -39,6 +39,7 @@ /** * Determine data directory. Let the user choose if the current one doesn't * exist. + * Let the user configure additional preferences such as pruning. * * @returns true if a data directory was selected, false if the user * cancelled the selection @@ -47,7 +48,8 @@ * @note do NOT call global GetDataDir() before calling this function, this * will cause the wrong path to be cached. */ - static bool showIfNeeded(interfaces::Node &node, bool &did_show_intro); + static bool showIfNeeded(interfaces::Node &node, bool &did_show_intro, + bool &prune); /** * Determine default data directory for operating system. diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -124,6 +124,14 @@ ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME)); uint64_t pruneTarget = std::max(0, gArgs.GetArg("-prune", 0)); + // -prune=1 means enabled, above that it's a size in MB + if (pruneTarget > 1) { + 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 " @@ -176,7 +184,8 @@ return GUIUtil::boostPathToQString(GetDefaultDataDir()); } -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; QSettings settings; @@ -238,6 +247,9 @@ } } + // Additional preferences: + prune = intro.ui->prune->isChecked(); + settings.setValue("strDataDir", dataDir); settings.setValue("fReset", false); }