aboutsummaryrefslogtreecommitdiff
path: root/src/qt/optionsmodel.cpp
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2019-04-29 15:29:00 -0400
committerRyan Ofsky <ryan@ofsky.org>2022-05-26 11:05:10 -0400
commit504b06b1dec9d9329c83b13c7c36ca710ebcd349 (patch)
tree529090def7d18bb5a291cc17a7d686c284084e97 /src/qt/optionsmodel.cpp
parent9a016a3c07d4becf0651ef58c7160180c5f25a0c (diff)
Migrate -lang setting from QSettings to settings.json
Diffstat (limited to 'src/qt/optionsmodel.cpp')
-rw-r--r--src/qt/optionsmodel.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 39e79a2a53..1b2bcefe94 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -53,6 +53,7 @@ static const char* SettingName(OptionsModel::OptionID option)
case OptionsModel::ProxyIPTor: return "onion";
case OptionsModel::ProxyPortTor: return "onion";
case OptionsModel::ProxyUseTor: return "onion";
+ case OptionsModel::Language: return "lang";
default: throw std::logic_error(strprintf("GUI option %i has no corresponding node setting.", option));
}
}
@@ -137,6 +138,7 @@ bool OptionsModel::Init(bilingual_str& error)
ProxySetting onion = ParseProxyString(SettingToString(node().getPersistentSetting("onion"), GetDefaultProxyAddress().toStdString()));
m_onion_ip = onion.ip;
m_onion_port = onion.port;
+ language = QString::fromStdString(SettingToString(node().getPersistentSetting("lang"), ""));
checkAndMigrate();
@@ -190,7 +192,7 @@ bool OptionsModel::Init(bilingual_str& error)
// These are shared with the core or have a command-line parameter
// and we want command-line parameters to overwrite the GUI settings.
for (OptionID option : {DatabaseCache, ThreadsScriptVerif, SpendZeroConfChange, ExternalSignerPath, MapPortUPnP,
- MapPortNatpmp, Listen, Server, Prune, ProxyUse, ProxyUseTor}) {
+ MapPortNatpmp, Listen, Server, Prune, ProxyUse, ProxyUseTor, Language}) {
std::string setting = SettingName(option);
if (node().isSettingIgnored(setting)) addOverriddenOption("-" + setting);
try {
@@ -205,9 +207,6 @@ bool OptionsModel::Init(bilingual_str& error)
}
// If setting doesn't exist create it with defaults.
- //
- // If gArgs.SoftSetArg() or gArgs.SoftSetBoolArg() return false we were overridden
- // by command-line and show this in the UI.
// Main
if (!settings.contains("strDataDir"))
@@ -222,13 +221,6 @@ bool OptionsModel::Init(bilingual_str& error)
#endif
// Display
- if (!settings.contains("language"))
- settings.setValue("language", "");
- if (!gArgs.SoftSetArg("-lang", settings.value("language").toString().toStdString()))
- addOverriddenOption("-lang");
-
- language = settings.value("language").toString();
-
if (!settings.contains("UseEmbeddedMonospacedFont")) {
settings.setValue("UseEmbeddedMonospacedFont", "true");
}
@@ -421,7 +413,7 @@ QVariant OptionsModel::getOption(OptionID option) const
case ThirdPartyTxUrls:
return strThirdPartyTxUrls;
case Language:
- return settings.value("language");
+ return QString::fromStdString(SettingToString(setting(), ""));
case UseEmbeddedMonospacedFont:
return m_use_embedded_monospaced_font;
case CoinControlFeatures:
@@ -564,8 +556,8 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value)
}
break;
case Language:
- if (settings.value("language") != value) {
- settings.setValue("language", value);
+ if (changed()) {
+ update(value.toString().toStdString());
setRestartRequired(true);
}
break;
@@ -711,6 +703,7 @@ void OptionsModel::checkAndMigrate()
migrate_setting(ProxyUse, "fUseProxy");
migrate_setting(ProxyIPTor, "addrSeparateProxyTor");
migrate_setting(ProxyUseTor, "fUseSeparateProxyTor");
+ migrate_setting(Language, "language");
// In case migrating QSettings caused any settings value to change, rerun
// parameter interaction code to update other settings. This is particularly