@@ -122,6 +122,18 @@ static const QLatin1String fontchoice_str_embedded{"embedded"};
122
122
static const QLatin1String fontchoice_str_best_system{" best_system" };
123
123
static const QString fontchoice_str_custom_prefix{QStringLiteral (" custom, " )};
124
124
125
+ QString OptionsModel::FontChoiceToString (const OptionsModel::FontChoice& f)
126
+ {
127
+ if (std::holds_alternative<FontChoiceAbstract>(f)) {
128
+ if (f == UseBestSystemFont) {
129
+ return fontchoice_str_best_system;
130
+ } else {
131
+ return fontchoice_str_embedded;
132
+ }
133
+ }
134
+ return fontchoice_str_custom_prefix + std::get<QFont>(f).toString ();
135
+ }
136
+
125
137
OptionsModel::FontChoice OptionsModel::FontChoiceFromString (const QString& s)
126
138
{
127
139
if (s == fontchoice_str_best_system) {
@@ -451,8 +463,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
451
463
return strThirdPartyTxUrls;
452
464
case Language:
453
465
return QString::fromStdString (SettingToString (setting (), " " ));
454
- case UseEmbeddedMonospacedFont :
455
- return (m_font_money != UseBestSystemFont );
466
+ case FontForMoney :
467
+ return QVariant::fromValue (m_font_money);
456
468
case CoinControlFeatures:
457
469
return fCoinControlFeatures ;
458
470
case EnablePSBTControls:
@@ -622,20 +634,12 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
622
634
setRestartRequired (true );
623
635
}
624
636
break ;
625
- case UseEmbeddedMonospacedFont :
637
+ case FontForMoney :
626
638
{
627
- const bool use_embedded_monospaced_font = value.toBool ();
628
- if (use_embedded_monospaced_font) {
629
- if (m_font_money != UseBestSystemFont) {
630
- // Leave it as-is
631
- break ;
632
- }
633
- m_font_money = FontChoiceAbstract::EmbeddedFont;
634
- } else {
635
- m_font_money = FontChoiceAbstract::BestSystemFont;
636
- }
637
- settings.setValue (" UseEmbeddedMonospacedFont" , use_embedded_monospaced_font);
638
- settings.remove (" FontForMoney" );
639
+ const auto & new_font = value.value <FontChoice>();
640
+ if (m_font_money == new_font) break ;
641
+ settings.setValue (" FontForMoney" , FontChoiceToString (new_font));
642
+ m_font_money = new_font;
639
643
Q_EMIT fontForMoneyChanged (getFontForMoney ());
640
644
break ;
641
645
}
0 commit comments