@@ -33,6 +33,18 @@ static const QLatin1String fontchoice_str_embedded{"embedded"};
3333static const QLatin1String fontchoice_str_best_system{" best_system" };
3434static const QString fontchoice_str_custom_prefix{QStringLiteral (" custom, " )};
3535
36+ QString OptionsModel::FontChoiceToString (const OptionsModel::FontChoice& f)
37+ {
38+ if (std::holds_alternative<FontChoiceAbstract>(f)) {
39+ if (f == UseBestSystemFont) {
40+ return fontchoice_str_best_system;
41+ } else {
42+ return fontchoice_str_embedded;
43+ }
44+ }
45+ return fontchoice_str_custom_prefix + std::get<QFont>(f).toString ();
46+ }
47+
3648OptionsModel::FontChoice OptionsModel::FontChoiceFromString (const QString& s)
3749{
3850 if (s == fontchoice_str_best_system) {
@@ -380,8 +392,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
380392 return strThirdPartyTxUrls;
381393 case Language:
382394 return settings.value (" language" );
383- case UseEmbeddedMonospacedFont :
384- return (m_font_money != UseBestSystemFont );
395+ case FontForMoney :
396+ return QVariant::fromValue (m_font_money);
385397 case CoinControlFeatures:
386398 return fCoinControlFeatures ;
387399 case Prune:
@@ -521,20 +533,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
521533 setRestartRequired (true );
522534 }
523535 break ;
524- case UseEmbeddedMonospacedFont :
536+ case FontForMoney :
525537 {
526- const bool use_embedded_monospaced_font = value.toBool ();
527- if (use_embedded_monospaced_font) {
528- if (m_font_money != UseBestSystemFont) {
529- // Leave it as-is
530- break ;
531- }
532- m_font_money = FontChoiceAbstract::EmbeddedFont;
533- } else {
534- m_font_money = FontChoiceAbstract::BestSystemFont;
535- }
536- settings.setValue (" UseEmbeddedMonospacedFont" , use_embedded_monospaced_font);
537- settings.remove (" FontForMoney" );
538+ const auto & new_font = value.value <FontChoice>();
539+ if (m_font_money == new_font) break ;
540+ settings.setValue (" FontForMoney" , FontChoiceToString (new_font));
541+ m_font_money = new_font;
538542 Q_EMIT fontForMoneyChanged (getFontForMoney ());
539543 break ;
540544 }
0 commit comments