@@ -118,6 +118,25 @@ struct ProxySetting {
118118static ProxySetting ParseProxyString (const std::string& proxy);
119119static std::string ProxyString (bool is_set, QString ip, QString port);
120120
121+ static const QLatin1String fontchoice_str_embedded{" embedded" };
122+ static const QLatin1String fontchoice_str_best_system{" best_system" };
123+ static const QString fontchoice_str_custom_prefix{QStringLiteral (" custom, " )};
124+
125+ OptionsModel::FontChoice OptionsModel::FontChoiceFromString (const QString& s)
126+ {
127+ if (s == fontchoice_str_best_system) {
128+ return FontChoiceAbstract::BestSystemFont;
129+ } else if (s == fontchoice_str_embedded) {
130+ return FontChoiceAbstract::EmbeddedFont;
131+ } else if (s.startsWith (fontchoice_str_custom_prefix)) {
132+ QFont f;
133+ f.fromString (s.mid (fontchoice_str_custom_prefix.size ()));
134+ return f;
135+ } else {
136+ return FontChoiceAbstract::EmbeddedFont; // default
137+ }
138+ }
139+
121140OptionsModel::OptionsModel (interfaces::Node& node, QObject *parent) :
122141 QAbstractListModel(parent), m_node{node}
123142{
@@ -215,13 +234,14 @@ bool OptionsModel::Init(bilingual_str& error)
215234#endif
216235
217236 // Display
218- if (!settings.contains (" UseEmbeddedMonospacedFont" )) {
219- settings.setValue (" UseEmbeddedMonospacedFont" , " true" );
220- }
221- if (settings.value (" UseEmbeddedMonospacedFont" ).toBool ()) {
222- m_font_money = FontChoiceAbstract::EmbeddedFont;
223- } else {
224- m_font_money = FontChoiceAbstract::BestSystemFont;
237+ if (settings.contains (" FontForMoney" )) {
238+ m_font_money = FontChoiceFromString (settings.value (" FontForMoney" ).toString ());
239+ } else if (settings.contains (" UseEmbeddedMonospacedFont" )) {
240+ if (settings.value (" UseEmbeddedMonospacedFont" ).toBool ()) {
241+ m_font_money = FontChoiceAbstract::EmbeddedFont;
242+ } else {
243+ m_font_money = FontChoiceAbstract::BestSystemFont;
244+ }
225245 }
226246 Q_EMIT fontForMoneyChanged (getFontForMoney ());
227247
@@ -615,6 +635,7 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
615635 m_font_money = FontChoiceAbstract::BestSystemFont;
616636 }
617637 settings.setValue (" UseEmbeddedMonospacedFont" , use_embedded_monospaced_font);
638+ settings.remove (" FontForMoney" );
618639 Q_EMIT fontForMoneyChanged (getFontForMoney ());
619640 break ;
620641 }
0 commit comments