aboutsummaryrefslogtreecommitdiff
path: root/src/qt/optionsmodel.cpp
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2021-12-02 16:59:46 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2023-07-21 17:45:36 +0000
commit98e9ac51992b2332587d87f25351988bf4863238 (patch)
tree4e971c4bbfeab4cadcf14e426d756bb2b3da0e16 /src/qt/optionsmodel.cpp
parent3a6757eed9a24e91e7d800d8026cc3a5c4840141 (diff)
GUI: Use FontChoice type in OptionsModel settings abstraction
Diffstat (limited to 'src/qt/optionsmodel.cpp')
-rw-r--r--src/qt/optionsmodel.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index a7aea31858..ef32a11523 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -122,6 +122,18 @@ static const QLatin1String fontchoice_str_embedded{"embedded"};
static const QLatin1String fontchoice_str_best_system{"best_system"};
static const QString fontchoice_str_custom_prefix{QStringLiteral("custom, ")};
+QString OptionsModel::FontChoiceToString(const OptionsModel::FontChoice& f)
+{
+ if (std::holds_alternative<FontChoiceAbstract>(f)) {
+ if (f == UseBestSystemFont) {
+ return fontchoice_str_best_system;
+ } else {
+ return fontchoice_str_embedded;
+ }
+ }
+ return fontchoice_str_custom_prefix + std::get<QFont>(f).toString();
+}
+
OptionsModel::FontChoice OptionsModel::FontChoiceFromString(const QString& s)
{
if (s == fontchoice_str_best_system) {
@@ -451,8 +463,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
return strThirdPartyTxUrls;
case Language:
return QString::fromStdString(SettingToString(setting(), ""));
- case UseEmbeddedMonospacedFont:
- return (m_font_money != UseBestSystemFont);
+ case FontForMoney:
+ return QVariant::fromValue(m_font_money);
case CoinControlFeatures:
return fCoinControlFeatures;
case EnablePSBTControls:
@@ -622,20 +634,12 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
setRestartRequired(true);
}
break;
- case UseEmbeddedMonospacedFont:
+ case FontForMoney:
{
- const bool use_embedded_monospaced_font = value.toBool();
- if (use_embedded_monospaced_font) {
- if (m_font_money != UseBestSystemFont) {
- // Leave it as-is
- break;
- }
- m_font_money = FontChoiceAbstract::EmbeddedFont;
- } else {
- m_font_money = FontChoiceAbstract::BestSystemFont;
- }
- settings.setValue("UseEmbeddedMonospacedFont", use_embedded_monospaced_font);
- settings.remove("FontForMoney");
+ const auto& new_font = value.value<FontChoice>();
+ if (m_font_money == new_font) break;
+ settings.setValue("FontForMoney", FontChoiceToString(new_font));
+ m_font_money = new_font;
Q_EMIT fontForMoneyChanged(getFontForMoney());
break;
}