qt: Persist Mask Values option

The mask values option is memory only. If a user has enabled this
option, it's reasonable to expect that they would want to have it
enabled on the next start.
This commit is contained in:
Andrew Chow 2023-01-23 19:12:04 -05:00
parent a62231bca6
commit 4de02def84
4 changed files with 13 additions and 0 deletions

View File

@ -647,6 +647,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
// initialize the disable state of the tray icon with the current value in the model. // initialize the disable state of the tray icon with the current value in the model.
trayIcon->setVisible(optionsModel->getShowTrayIcon()); trayIcon->setVisible(optionsModel->getShowTrayIcon());
} }
m_mask_values_action->setChecked(_clientModel->getOptionsModel()->getOption(OptionsModel::OptionID::MaskValues).toBool());
} else { } else {
if(trayIconMenu) if(trayIconMenu)
{ {

View File

@ -227,6 +227,8 @@ bool OptionsModel::Init(bilingual_str& error)
m_use_embedded_monospaced_font = settings.value("UseEmbeddedMonospacedFont").toBool(); m_use_embedded_monospaced_font = settings.value("UseEmbeddedMonospacedFont").toBool();
Q_EMIT useEmbeddedMonospacedFontChanged(m_use_embedded_monospaced_font); Q_EMIT useEmbeddedMonospacedFontChanged(m_use_embedded_monospaced_font);
m_mask_values = settings.value("mask_values", false).toBool();
return true; return true;
} }
@ -435,6 +437,8 @@ QVariant OptionsModel::getOption(OptionID option) const
return SettingToBool(setting(), DEFAULT_LISTEN); return SettingToBool(setting(), DEFAULT_LISTEN);
case Server: case Server:
return SettingToBool(setting(), false); return SettingToBool(setting(), false);
case MaskValues:
return m_mask_values;
default: default:
return QVariant(); return QVariant();
} }
@ -612,6 +616,10 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value)
setRestartRequired(true); setRestartRequired(true);
} }
break; break;
case MaskValues:
m_mask_values = value.toBool();
settings.setValue("mask_values", m_mask_values);
break;
default: default:
break; break;
} }

View File

@ -72,6 +72,7 @@ public:
Listen, // bool Listen, // bool
Server, // bool Server, // bool
EnablePSBTControls, // bool EnablePSBTControls, // bool
MaskValues, // bool
OptionIDRowCount, OptionIDRowCount,
}; };
@ -120,6 +121,7 @@ private:
bool fCoinControlFeatures; bool fCoinControlFeatures;
bool m_sub_fee_from_amount; bool m_sub_fee_from_amount;
bool m_enable_psbt_controls; bool m_enable_psbt_controls;
bool m_mask_values;
//! In-memory settings for display. These are stored persistently by the //! In-memory settings for display. These are stored persistently by the
//! bitcoin node but it's also nice to store them in memory to prevent them //! bitcoin node but it's also nice to store them in memory to prevent them

View File

@ -173,6 +173,7 @@ void OverviewPage::handleTransactionClicked(const QModelIndex &index)
void OverviewPage::setPrivacy(bool privacy) void OverviewPage::setPrivacy(bool privacy)
{ {
m_privacy = privacy; m_privacy = privacy;
clientModel->getOptionsModel()->setOption(OptionsModel::OptionID::MaskValues, privacy);
const auto& balances = walletModel->getCachedBalance(); const auto& balances = walletModel->getCachedBalance();
if (balances.balance != -1) { if (balances.balance != -1) {
setBalance(balances); setBalance(balances);