mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-30 10:42:23 +02:00
GUI: Load custom FontForMoney from QSettings
This commit is contained in:
@ -118,6 +118,25 @@ struct ProxySetting {
|
|||||||
static ProxySetting ParseProxyString(const std::string& proxy);
|
static ProxySetting ParseProxyString(const std::string& proxy);
|
||||||
static std::string ProxyString(bool is_set, QString ip, QString port);
|
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) :
|
OptionsModel::OptionsModel(interfaces::Node& node, QObject *parent) :
|
||||||
QAbstractListModel(parent), m_node{node}
|
QAbstractListModel(parent), m_node{node}
|
||||||
{
|
{
|
||||||
@ -215,13 +234,14 @@ bool OptionsModel::Init(bilingual_str& error)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Display
|
// Display
|
||||||
if (!settings.contains("UseEmbeddedMonospacedFont")) {
|
if (settings.contains("FontForMoney")) {
|
||||||
settings.setValue("UseEmbeddedMonospacedFont", "true");
|
m_font_money = FontChoiceFromString(settings.value("FontForMoney").toString());
|
||||||
}
|
} else if (settings.contains("UseEmbeddedMonospacedFont")) {
|
||||||
if (settings.value("UseEmbeddedMonospacedFont").toBool()) {
|
if (settings.value("UseEmbeddedMonospacedFont").toBool()) {
|
||||||
m_font_money = FontChoiceAbstract::EmbeddedFont;
|
m_font_money = FontChoiceAbstract::EmbeddedFont;
|
||||||
} else {
|
} else {
|
||||||
m_font_money = FontChoiceAbstract::BestSystemFont;
|
m_font_money = FontChoiceAbstract::BestSystemFont;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
||||||
|
|
||||||
@ -615,6 +635,7 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
|
|||||||
m_font_money = FontChoiceAbstract::BestSystemFont;
|
m_font_money = FontChoiceAbstract::BestSystemFont;
|
||||||
}
|
}
|
||||||
settings.setValue("UseEmbeddedMonospacedFont", use_embedded_monospaced_font);
|
settings.setValue("UseEmbeddedMonospacedFont", use_embedded_monospaced_font);
|
||||||
|
settings.remove("FontForMoney");
|
||||||
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ private:
|
|||||||
QString language;
|
QString language;
|
||||||
BitcoinUnit m_display_bitcoin_unit;
|
BitcoinUnit m_display_bitcoin_unit;
|
||||||
QString strThirdPartyTxUrls;
|
QString strThirdPartyTxUrls;
|
||||||
FontChoice m_font_money;
|
FontChoice m_font_money{FontChoiceAbstract::EmbeddedFont};
|
||||||
bool fCoinControlFeatures;
|
bool fCoinControlFeatures;
|
||||||
bool m_sub_fee_from_amount;
|
bool m_sub_fee_from_amount;
|
||||||
bool m_enable_psbt_controls;
|
bool m_enable_psbt_controls;
|
||||||
@ -138,6 +138,8 @@ private:
|
|||||||
/* settings that were overridden by command-line */
|
/* settings that were overridden by command-line */
|
||||||
QString strOverriddenByCommandLine;
|
QString strOverriddenByCommandLine;
|
||||||
|
|
||||||
|
static FontChoice FontChoiceFromString(const QString&);
|
||||||
|
|
||||||
// Add option to list of GUI options overridden through command line/config file
|
// Add option to list of GUI options overridden through command line/config file
|
||||||
void addOverriddenOption(const std::string &option);
|
void addOverriddenOption(const std::string &option);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user