@@ -122,6 +122,18 @@ static const QLatin1String fontchoice_str_embedded{"embedded"};
122122static const QLatin1String fontchoice_str_best_system{" best_system" };
123123static const QString fontchoice_str_custom_prefix{QStringLiteral (" custom, " )};
124124
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+
125137OptionsModel::FontChoice OptionsModel::FontChoiceFromString (const QString& s)
126138{
127139 if (s == fontchoice_str_best_system) {
@@ -451,8 +463,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
451463 return strThirdPartyTxUrls;
452464 case Language:
453465 return QString::fromStdString (SettingToString (setting (), " " ));
454- case UseEmbeddedMonospacedFont :
455- return (m_font_money != UseBestSystemFont );
466+ case FontForMoney :
467+ return QVariant::fromValue (m_font_money);
456468 case CoinControlFeatures:
457469 return fCoinControlFeatures ;
458470 case EnablePSBTControls:
@@ -622,20 +634,12 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
622634 setRestartRequired (true );
623635 }
624636 break ;
625- case UseEmbeddedMonospacedFont :
637+ case FontForMoney :
626638 {
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;
639643 Q_EMIT fontForMoneyChanged (getFontForMoney ());
640644 break ;
641645 }
0 commit comments