aboutsummaryrefslogtreecommitdiff
path: root/src/qt/optionsmodel.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-04-20 22:15:39 +0300
committerWilliam Casarin <jb55@jb55.com>2022-02-22 13:50:30 -0800
commit0554251d660caa1c3f5f44ae1d9fa3c23d2aac18 (patch)
tree1c7662f34c4b5852e6796d65e75628653cfca3a5 /src/qt/optionsmodel.cpp
parentffbc2fe459034024cb2fce9fd94bff457b7a7d49 (diff)
qt: Skip displayUnitChanged signal if unit is not actually changed
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
Diffstat (limited to 'src/qt/optionsmodel.cpp')
-rw-r--r--src/qt/optionsmodel.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index a0d35b6c5f..ebceccac8b 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -572,15 +572,13 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
return successful;
}
-/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
-void OptionsModel::setDisplayUnit(const QVariant &value)
+void OptionsModel::setDisplayUnit(const QVariant& new_unit)
{
- if (!value.isNull()) {
- QSettings settings;
- m_display_bitcoin_unit = value.value<BitcoinUnit>();
- settings.setValue("DisplayBitcoinUnit", QVariant::fromValue(m_display_bitcoin_unit));
- Q_EMIT displayUnitChanged(m_display_bitcoin_unit);
- }
+ if (new_unit.isNull() || new_unit.value<BitcoinUnit>() == m_display_bitcoin_unit) return;
+ m_display_bitcoin_unit = new_unit.value<BitcoinUnit>();
+ QSettings settings;
+ settings.setValue("DisplayBitcoinUnit", QVariant::fromValue(m_display_bitcoin_unit));
+ Q_EMIT displayUnitChanged(m_display_bitcoin_unit);
}
void OptionsModel::setRestartRequired(bool fRequired)