Writes all missing QSettings with their default values
| 158 | |
| 159 | // Writes all missing QSettings with their default values |
| 160 | bool OptionsModel::Init(bilingual_str& error) |
| 161 | { |
| 162 | // Initialize display settings from stored settings. |
| 163 | language = QString::fromStdString(SettingToString(node().getPersistentSetting("lang"), "")); |
| 164 | |
| 165 | checkAndMigrate(); |
| 166 | |
| 167 | QSettings settings; |
| 168 | |
| 169 | // Ensure restart flag is unset on client startup |
| 170 | setRestartRequired(false); |
| 171 | |
| 172 | // These are Qt-only settings: |
| 173 | |
| 174 | // Window |
| 175 | if (!settings.contains("fHideTrayIcon")) { |
| 176 | settings.setValue("fHideTrayIcon", false); |
| 177 | } |
| 178 | m_show_tray_icon = !settings.value("fHideTrayIcon").toBool(); |
| 179 | Q_EMIT showTrayIconChanged(m_show_tray_icon); |
| 180 | |
| 181 | if (!settings.contains("fMinimizeToTray")) |
| 182 | settings.setValue("fMinimizeToTray", false); |
| 183 | fMinimizeToTray = settings.value("fMinimizeToTray").toBool() && m_show_tray_icon; |
| 184 | |
| 185 | if (!settings.contains("fMinimizeOnClose")) |
| 186 | settings.setValue("fMinimizeOnClose", false); |
| 187 | fMinimizeOnClose = settings.value("fMinimizeOnClose").toBool(); |
| 188 | |
| 189 | // Display |
| 190 | if (!settings.contains("DisplayBitcoinUnit")) { |
| 191 | settings.setValue("DisplayBitcoinUnit", QVariant::fromValue(BitcoinUnit::BTC)); |
| 192 | } |
| 193 | QVariant unit = settings.value("DisplayBitcoinUnit"); |
| 194 | if (unit.canConvert<BitcoinUnit>()) { |
| 195 | m_display_bitcoin_unit = unit.value<BitcoinUnit>(); |
| 196 | } else { |
| 197 | m_display_bitcoin_unit = BitcoinUnit::BTC; |
| 198 | settings.setValue("DisplayBitcoinUnit", QVariant::fromValue(m_display_bitcoin_unit)); |
| 199 | } |
| 200 | |
| 201 | if (!settings.contains("strThirdPartyTxUrls")) |
| 202 | settings.setValue("strThirdPartyTxUrls", ""); |
| 203 | strThirdPartyTxUrls = settings.value("strThirdPartyTxUrls", "").toString(); |
| 204 | |
| 205 | if (!settings.contains("fCoinControlFeatures")) |
| 206 | settings.setValue("fCoinControlFeatures", false); |
| 207 | fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool(); |
| 208 | |
| 209 | if (!settings.contains("enable_psbt_controls")) { |
| 210 | settings.setValue("enable_psbt_controls", false); |
| 211 | } |
| 212 | m_enable_psbt_controls = settings.value("enable_psbt_controls", false).toBool(); |
| 213 | |
| 214 | // These are shared with the core or have a command-line parameter |
| 215 | // and we want command-line parameters to overwrite the GUI settings. |
| 216 | for (OptionID option : {DatabaseCache, ThreadsScriptVerif, SpendZeroConfChange, ExternalSignerPath, |
| 217 | MapPortNatpmp, Listen, Server, Prune, ProxyUse, ProxyUseTor, Language}) { |