aboutsummaryrefslogtreecommitdiff
path: root/src/qt/optionsmodel.cpp
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2021-12-02 02:25:30 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2023-07-21 17:45:36 +0000
commit3a6757eed9a24e91e7d800d8026cc3a5c4840141 (patch)
treeace461f771584e171ea50a46202842ded1c525a1 /src/qt/optionsmodel.cpp
parent49eb97eff96c2ec9e5a55d599f18b1866f83b115 (diff)
downloadbitcoin-3a6757eed9a24e91e7d800d8026cc3a5c4840141.tar.xz
GUI: Load custom FontForMoney from QSettings
Diffstat (limited to 'src/qt/optionsmodel.cpp')
-rw-r--r--src/qt/optionsmodel.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index a8f20fec23..a7aea31858 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -118,6 +118,25 @@ struct ProxySetting {
static ProxySetting ParseProxyString(const std::string& proxy);
static std::string ProxyString(bool is_set, QString ip, QString port);
+static const QLatin1String fontchoice_str_embedded{"embedded"};
+static const QLatin1String fontchoice_str_best_system{"best_system"};
+static const QString fontchoice_str_custom_prefix{QStringLiteral("custom, ")};
+
+OptionsModel::FontChoice OptionsModel::FontChoiceFromString(const QString& s)
+{
+ if (s == fontchoice_str_best_system) {
+ return FontChoiceAbstract::BestSystemFont;
+ } else if (s == fontchoice_str_embedded) {
+ return FontChoiceAbstract::EmbeddedFont;
+ } else if (s.startsWith(fontchoice_str_custom_prefix)) {
+ QFont f;
+ f.fromString(s.mid(fontchoice_str_custom_prefix.size()));
+ return f;
+ } else {
+ return FontChoiceAbstract::EmbeddedFont; // default
+ }
+}
+
OptionsModel::OptionsModel(interfaces::Node& node, QObject *parent) :
QAbstractListModel(parent), m_node{node}
{
@@ -215,13 +234,14 @@ bool OptionsModel::Init(bilingual_str& error)
#endif
// Display
- if (!settings.contains("UseEmbeddedMonospacedFont")) {
- settings.setValue("UseEmbeddedMonospacedFont", "true");
- }
- if (settings.value("UseEmbeddedMonospacedFont").toBool()) {
- m_font_money = FontChoiceAbstract::EmbeddedFont;
- } else {
- m_font_money = FontChoiceAbstract::BestSystemFont;
+ if (settings.contains("FontForMoney")) {
+ m_font_money = FontChoiceFromString(settings.value("FontForMoney").toString());
+ } else if (settings.contains("UseEmbeddedMonospacedFont")) {
+ if (settings.value("UseEmbeddedMonospacedFont").toBool()) {
+ m_font_money = FontChoiceAbstract::EmbeddedFont;
+ } else {
+ m_font_money = FontChoiceAbstract::BestSystemFont;
+ }
}
Q_EMIT fontForMoneyChanged(getFontForMoney());
@@ -615,6 +635,7 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
m_font_money = FontChoiceAbstract::BestSystemFont;
}
settings.setValue("UseEmbeddedMonospacedFont", use_embedded_monospaced_font);
+ settings.remove("FontForMoney");
Q_EMIT fontForMoneyChanged(getFontForMoney());
break;
}