Changeset View
Changeset View
Standalone View
Standalone View
src/qt/optionsmodel.cpp
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | void OptionsModel::Init(bool resetSettings) { | ||||
// Main | // Main | ||||
if (!settings.contains("bPrune")) { | if (!settings.contains("bPrune")) { | ||||
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); | ||||
} | } | ||||
if (!m_node.softSetArg( | if (!m_node.softSetArg( | ||||
"-dbcache", | "-dbcache", | ||||
settings.value("nDatabaseCache").toString().toStdString())) { | settings.value("nDatabaseCache").toString().toStdString())) { | ||||
addOverriddenOption("-dbcache"); | addOverriddenOption("-dbcache"); | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static const QString GetDefaultProxyAddress() { | static const QString GetDefaultProxyAddress() { | ||||
return QString("%1:%2") | return QString("%1:%2") | ||||
.arg(DEFAULT_GUI_PROXY_HOST) | .arg(DEFAULT_GUI_PROXY_HOST) | ||||
.arg(DEFAULT_GUI_PROXY_PORT); | .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 { | ||||
if (role == Qt::EditRole) { | if (role == Qt::EditRole) { | ||||
QSettings settings; | QSettings settings; | ||||
switch (index.row()) { | switch (index.row()) { | ||||
case StartAtStartup: | case StartAtStartup: | ||||
return GUIUtil::GetStartOnSystemStartup(); | return GUIUtil::GetStartOnSystemStartup(); | ||||
case HideTrayIcon: | case HideTrayIcon: | ||||
▲ Show 20 Lines • Show All 278 Lines • Show Last 20 Lines |