@@ -33,6 +33,18 @@ static const QLatin1String fontchoice_str_embedded{"embedded"};
33
33
static const QLatin1String fontchoice_str_best_system{" best_system" };
34
34
static const QString fontchoice_str_custom_prefix{QStringLiteral (" custom, " )};
35
35
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
+
36
48
OptionsModel::FontChoice OptionsModel::FontChoiceFromString (const QString& s)
37
49
{
38
50
if (s == fontchoice_str_best_system) {
@@ -380,8 +392,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
380
392
return strThirdPartyTxUrls;
381
393
case Language:
382
394
return settings.value (" language" );
383
- case UseEmbeddedMonospacedFont :
384
- return (m_font_money != UseBestSystemFont );
395
+ case FontForMoney :
396
+ return QVariant::fromValue (m_font_money);
385
397
case CoinControlFeatures:
386
398
return fCoinControlFeatures ;
387
399
case Prune:
@@ -521,20 +533,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
521
533
setRestartRequired (true );
522
534
}
523
535
break ;
524
- case UseEmbeddedMonospacedFont :
536
+ case FontForMoney :
525
537
{
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;
538
542
Q_EMIT fontForMoneyChanged (getFontForMoney ());
539
543
break ;
540
544
}
0 commit comments