mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-14 20:09:19 +02:00
[gui] add explicit prune setter
This makes it possible to enable pruning after the OptionsModel has been initialized and reset.
This commit is contained in:
@@ -282,6 +282,10 @@ void BitcoinApplication::parameterSetup()
|
|||||||
m_node.initParameterInteraction();
|
m_node.initParameterInteraction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BitcoinApplication::SetPrune(bool prune, bool force) {
|
||||||
|
optionsModel->SetPrune(prune, force);
|
||||||
|
}
|
||||||
|
|
||||||
void BitcoinApplication::requestInitialize()
|
void BitcoinApplication::requestInitialize()
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << ": Requesting initialize";
|
qDebug() << __func__ << ": Requesting initialize";
|
||||||
|
@@ -67,6 +67,8 @@ public:
|
|||||||
void parameterSetup();
|
void parameterSetup();
|
||||||
/// Create options model
|
/// Create options model
|
||||||
void createOptionsModel(bool resetSettings);
|
void createOptionsModel(bool resetSettings);
|
||||||
|
/// Update prune value
|
||||||
|
void SetPrune(bool prune, bool force = false);
|
||||||
/// Create main window
|
/// Create main window
|
||||||
void createWindow(const NetworkStyle *networkStyle);
|
void createWindow(const NetworkStyle *networkStyle);
|
||||||
/// Create splash screen
|
/// Create splash screen
|
||||||
|
@@ -92,11 +92,7 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
settings.setValue("bPrune", false);
|
settings.setValue("bPrune", false);
|
||||||
if (!settings.contains("nPruneSize"))
|
if (!settings.contains("nPruneSize"))
|
||||||
settings.setValue("nPruneSize", 2);
|
settings.setValue("nPruneSize", 2);
|
||||||
// Convert prune size from GB to MiB:
|
SetPrune(settings.value("bPrune").toBool());
|
||||||
const uint64_t nPruneSizeMiB = (settings.value("nPruneSize").toInt() * GB_BYTES) >> 20;
|
|
||||||
if (!m_node.softSetArg("-prune", settings.value("bPrune").toBool() ? std::to_string(nPruneSizeMiB) : "0")) {
|
|
||||||
addOverriddenOption("-prune");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!settings.contains("nDatabaseCache"))
|
if (!settings.contains("nDatabaseCache"))
|
||||||
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
|
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
|
||||||
@@ -240,6 +236,22 @@ static const QString GetDefaultProxyAddress()
|
|||||||
return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT);
|
return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsModel::SetPrune(bool prune, bool force)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue("bPrune", prune);
|
||||||
|
// Convert prune size from GB to MiB:
|
||||||
|
const uint64_t nPruneSizeMiB = (settings.value("nPruneSize").toInt() * GB_BYTES) >> 20;
|
||||||
|
std::string prune_val = prune ? std::to_string(nPruneSizeMiB) : "0";
|
||||||
|
if (force) {
|
||||||
|
m_node.forceSetArg("-prune", prune_val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!m_node.softSetArg("-prune", prune_val)) {
|
||||||
|
addOverriddenOption("-prune");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// read QSettings values and return them
|
// read QSettings values and return them
|
||||||
QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||||
{
|
{
|
||||||
|
@@ -77,6 +77,9 @@ public:
|
|||||||
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
|
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
|
||||||
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
|
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
|
||||||
|
|
||||||
|
/* Explicit setters */
|
||||||
|
void SetPrune(bool prune, bool force = false);
|
||||||
|
|
||||||
/* Restart flag helper */
|
/* Restart flag helper */
|
||||||
void setRestartRequired(bool fRequired);
|
void setRestartRequired(bool fRequired);
|
||||||
bool isRestartRequired() const;
|
bool isRestartRequired() const;
|
||||||
|
Reference in New Issue
Block a user