fix settings

This commit is contained in:
UdjinM6 2016-02-15 03:08:48 +03:00
parent 0e55aeb538
commit bff701f420
3 changed files with 45 additions and 40 deletions

View File

@ -218,7 +218,6 @@ void OptionsDialog::setMapper()
/* Display */ /* Display */
mapper->addMapping(ui->digits, OptionsModel::Digits); mapper->addMapping(ui->digits, OptionsModel::Digits);
mapper->addMapping(ui->theme, OptionsModel::Theme); mapper->addMapping(ui->theme, OptionsModel::Theme);
mapper->addMapping(ui->theme, OptionsModel::Theme);
mapper->addMapping(ui->lang, OptionsModel::Language); mapper->addMapping(ui->lang, OptionsModel::Language);
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit); mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls); mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls);

View File

@ -44,7 +44,7 @@ void OptionsModel::Init(bool resetSettings)
if (resetSettings) if (resetSettings)
Reset(); Reset();
resetSettings = false; this->resetSettings = resetSettings;
QSettings settings; QSettings settings;
@ -75,19 +75,10 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("fCoinControlFeatures", false); settings.setValue("fCoinControlFeatures", false);
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool(); fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
if (!settings.contains("nDarksendRounds")) if (!settings.contains("digits"))
settings.setValue("nDarksendRounds", 2); settings.setValue("digits", "2");
if (!settings.contains("theme"))
if (!settings.contains("nAnonymizeDashAmount")) { settings.setValue("theme", "");
// for migration from old settings
if (!settings.contains("nAnonymizeDarkcoinAmount"))
settings.setValue("nAnonymizeDashAmount", 1000);
else
settings.setValue("nAnonymizeDashAmount", settings.value("nAnonymizeDarkcoinAmount"));
}
nDarksendRounds = settings.value("nDarksendRounds").toLongLong();
nAnonymizeDashAmount = settings.value("nAnonymizeDashAmount").toLongLong();
// These are shared with the core or have a command-line parameter // These are shared with the core or have a command-line parameter
// and we want command-line parameters to overwrite the GUI settings. // and we want command-line parameters to overwrite the GUI settings.
@ -114,6 +105,24 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("bSpendZeroConfChange", true); settings.setValue("bSpendZeroConfChange", true);
if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool())) if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
addOverriddenOption("-spendzeroconfchange"); addOverriddenOption("-spendzeroconfchange");
// Darksend
if (!settings.contains("nDarksendRounds"))
settings.setValue("nDarksendRounds", 2);
if (!SoftSetArg("-darksendrounds", settings.value("nDarksendRounds").toString().toStdString()))
addOverriddenOption("-darksendrounds");
nDarksendRounds = settings.value("nDarksendRounds").toInt();
if (!settings.contains("nAnonymizeDashAmount")) {
// for migration from old settings
if (!settings.contains("nAnonymizeDarkcoinAmount"))
settings.setValue("nAnonymizeDashAmount", 1000);
else
settings.setValue("nAnonymizeDashAmount", settings.value("nAnonymizeDarkcoinAmount").toInt());
}
if (!SoftSetArg("-anonymizedashamount", settings.value("nAnonymizeDashAmount").toString().toStdString()))
addOverriddenOption("-anonymizedashamount");
nAnonymizeDashAmount = settings.value("nAnonymizeDashAmount").toInt();
#endif #endif
// Network // Network
@ -148,20 +157,11 @@ void OptionsModel::Init(bool resetSettings)
addOverriddenOption("-onion"); addOverriddenOption("-onion");
// Display // Display
if (!settings.contains("digits"))
settings.setValue("digits", "2");
if (!settings.contains("theme"))
settings.setValue("theme", "");
if (!settings.contains("language")) if (!settings.contains("language"))
settings.setValue("language", ""); settings.setValue("language", "");
if (!SoftSetArg("-lang", settings.value("language").toString().toStdString())) if (!SoftSetArg("-lang", settings.value("language").toString().toStdString()))
addOverriddenOption("-lang"); addOverriddenOption("-lang");
if (settings.contains("nDarksendRounds"))
SoftSetArg("-darksendrounds", settings.value("nDarksendRounds").toString().toStdString());
if (settings.contains("nAnonymizeDashAmount"))
SoftSetArg("-anonymizedashamount", settings.value("nAnonymizeDashAmount").toString().toStdString());
language = settings.value("language").toString(); language = settings.value("language").toString();
} }
@ -235,6 +235,10 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
case SpendZeroConfChange: case SpendZeroConfChange:
return settings.value("bSpendZeroConfChange"); return settings.value("bSpendZeroConfChange");
case DarksendRounds:
return settings.value("nDarksendRounds");
case AnonymizeDashAmount:
return settings.value("nAnonymizeDashAmount");
#endif #endif
case DisplayUnit: case DisplayUnit:
return nDisplayUnit; return nDisplayUnit;
@ -252,10 +256,6 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return settings.value("nDatabaseCache"); return settings.value("nDatabaseCache");
case ThreadsScriptVerif: case ThreadsScriptVerif:
return settings.value("nThreadsScriptVerif"); return settings.value("nThreadsScriptVerif");
case DarksendRounds:
return QVariant(nDarksendRounds);
case AnonymizeDashAmount:
return QVariant(nAnonymizeDashAmount);
case Listen: case Listen:
return settings.value("fListen"); return settings.value("fListen");
default: default:
@ -361,6 +361,22 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
setRestartRequired(true); setRestartRequired(true);
} }
break; break;
case DarksendRounds:
if (settings.value("nDarksendRounds") != value)
{
nDarksendRounds = value.toInt();
settings.setValue("nDarksendRounds", nDarksendRounds);
Q_EMIT darksendRoundsChanged(nDarksendRounds);
}
break;
case AnonymizeDashAmount:
if (settings.value("nAnonymizeDashAmount") != value)
{
nAnonymizeDashAmount = value.toInt();
settings.setValue("nAnonymizeDashAmount", nAnonymizeDashAmount);
Q_EMIT anonymizeDashAmountChanged(nAnonymizeDashAmount);
}
break;
#endif #endif
case DisplayUnit: case DisplayUnit:
setDisplayUnit(value); setDisplayUnit(value);
@ -390,16 +406,6 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
setRestartRequired(true); setRestartRequired(true);
} }
break; break;
case DarksendRounds:
nDarksendRounds = value.toInt();
settings.setValue("nDarksendRounds", nDarksendRounds);
Q_EMIT darksendRoundsChanged(nDarksendRounds);
break;
case AnonymizeDashAmount:
nAnonymizeDashAmount = value.toInt();
settings.setValue("nAnonymizeDashAmount", nAnonymizeDashAmount);
Q_EMIT anonymizeDashAmountChanged(nAnonymizeDashAmount);
break;
case CoinControlFeatures: case CoinControlFeatures:
fCoinControlFeatures = value.toBool(); fCoinControlFeatures = value.toBool();
settings.setValue("fCoinControlFeatures", fCoinControlFeatures); settings.setValue("fCoinControlFeatures", fCoinControlFeatures);