@@ -29,6 +29,25 @@ const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1";
2929
3030static const QString GetDefaultProxyAddress ();
3131
32+ static const QLatin1String fontchoice_str_embedded{" embedded" };
33+ static const QLatin1String fontchoice_str_best_system{" best_system" };
34+ static const QString fontchoice_str_custom_prefix{QStringLiteral (" custom, " )};
35+
36+ OptionsModel::FontChoice OptionsModel::FontChoiceFromString (const QString& s)
37+ {
38+ if (s == fontchoice_str_best_system) {
39+ return FontChoiceAbstract::BestSystemFont;
40+ } else if (s == fontchoice_str_embedded) {
41+ return FontChoiceAbstract::EmbeddedFont;
42+ } else if (s.startsWith (fontchoice_str_custom_prefix)) {
43+ QFont f;
44+ f.fromString (s.mid (fontchoice_str_custom_prefix.size ()));
45+ return f;
46+ } else {
47+ return FontChoiceAbstract::EmbeddedFont; // default
48+ }
49+ }
50+
3251OptionsModel::OptionsModel (QObject *parent, bool resetSettings) :
3352 QAbstractListModel(parent)
3453{
@@ -184,13 +203,14 @@ void OptionsModel::Init(bool resetSettings)
184203
185204 language = settings.value (" language" ).toString ();
186205
187- if (!settings.contains (" UseEmbeddedMonospacedFont" )) {
188- settings.setValue (" UseEmbeddedMonospacedFont" , " true" );
189- }
190- if (settings.value (" UseEmbeddedMonospacedFont" ).toBool ()) {
191- m_font_money = FontChoiceAbstract::EmbeddedFont;
192- } else {
193- m_font_money = FontChoiceAbstract::BestSystemFont;
206+ if (settings.contains (" FontForMoney" )) {
207+ m_font_money = FontChoiceFromString (settings.value (" FontForMoney" ).toString ());
208+ } else if (settings.contains (" UseEmbeddedMonospacedFont" )) {
209+ if (settings.value (" UseEmbeddedMonospacedFont" ).toBool ()) {
210+ m_font_money = FontChoiceAbstract::EmbeddedFont;
211+ } else {
212+ m_font_money = FontChoiceAbstract::BestSystemFont;
213+ }
194214 }
195215 Q_EMIT fontForMoneyChanged (getFontForMoney ());
196216}
@@ -514,6 +534,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
514534 m_font_money = FontChoiceAbstract::BestSystemFont;
515535 }
516536 settings.setValue (" UseEmbeddedMonospacedFont" , use_embedded_monospaced_font);
537+ settings.remove (" FontForMoney" );
517538 Q_EMIT fontForMoneyChanged (getFontForMoney ());
518539 break ;
519540 }
0 commit comments