diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2019-04-29 15:29:00 -0400 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2022-05-26 11:05:10 -0400 |
commit | 504b06b1dec9d9329c83b13c7c36ca710ebcd349 (patch) | |
tree | 529090def7d18bb5a291cc17a7d686c284084e97 /src/qt | |
parent | 9a016a3c07d4becf0651ef58c7160180c5f25a0c (diff) | |
download | bitcoin-504b06b1dec9d9329c83b13c7c36ca710ebcd349.tar.xz |
Migrate -lang setting from QSettings to settings.json
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/forms/optionsdialog.ui | 2 | ||||
-rw-r--r-- | src/qt/optionsmodel.cpp | 21 |
2 files changed, 8 insertions, 15 deletions
diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 5438811aff..582f02132a 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -896,7 +896,7 @@ <item> <widget class="QLabel" name="overriddenByCommandLineInfoLabel"> <property name="text"> - <string>Options set in this dialog are overridden by the command line or in the configuration file:</string> + <string>Options set in this dialog are overridden by the command line:</string> </property> <property name="textFormat"> <enum>Qt::PlainText</enum> 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 |