mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
GUI: Add possibility for an explicit QFont for FontForMoney in OptionsModel
This commit is contained in:
parent
f2dfde80b8
commit
49eb97eff9
2 changed files with 36 additions and 7 deletions
|
@ -218,7 +218,11 @@ bool OptionsModel::Init(bilingual_str& error)
|
|||
if (!settings.contains("UseEmbeddedMonospacedFont")) {
|
||||
settings.setValue("UseEmbeddedMonospacedFont", "true");
|
||||
}
|
||||
m_use_embedded_monospaced_font = settings.value("UseEmbeddedMonospacedFont").toBool();
|
||||
if (settings.value("UseEmbeddedMonospacedFont").toBool()) {
|
||||
m_font_money = FontChoiceAbstract::EmbeddedFont;
|
||||
} else {
|
||||
m_font_money = FontChoiceAbstract::BestSystemFont;
|
||||
}
|
||||
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
||||
|
||||
m_mask_values = settings.value("mask_values", false).toBool();
|
||||
|
@ -428,7 +432,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
|
|||
case Language:
|
||||
return QString::fromStdString(SettingToString(setting(), ""));
|
||||
case UseEmbeddedMonospacedFont:
|
||||
return m_use_embedded_monospaced_font;
|
||||
return (m_font_money != UseBestSystemFont);
|
||||
case CoinControlFeatures:
|
||||
return fCoinControlFeatures;
|
||||
case EnablePSBTControls:
|
||||
|
@ -456,8 +460,13 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
|
|||
|
||||
QFont OptionsModel::getFontForMoney() const
|
||||
{
|
||||
QFont f = GUIUtil::fixedPitchFont(m_use_embedded_monospaced_font);
|
||||
f.setWeight(QFont::Bold);
|
||||
QFont f;
|
||||
if (std::holds_alternative<FontChoiceAbstract>(m_font_money)) {
|
||||
f = GUIUtil::fixedPitchFont(m_font_money != UseBestSystemFont);
|
||||
f.setWeight(QFont::Bold);
|
||||
} else {
|
||||
f = std::get<QFont>(m_font_money);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
|
@ -594,10 +603,21 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
|
|||
}
|
||||
break;
|
||||
case UseEmbeddedMonospacedFont:
|
||||
m_use_embedded_monospaced_font = value.toBool();
|
||||
settings.setValue("UseEmbeddedMonospacedFont", m_use_embedded_monospaced_font);
|
||||
{
|
||||
const bool use_embedded_monospaced_font = value.toBool();
|
||||
if (use_embedded_monospaced_font) {
|
||||
if (m_font_money != UseBestSystemFont) {
|
||||
// Leave it as-is
|
||||
break;
|
||||
}
|
||||
m_font_money = FontChoiceAbstract::EmbeddedFont;
|
||||
} else {
|
||||
m_font_money = FontChoiceAbstract::BestSystemFont;
|
||||
}
|
||||
settings.setValue("UseEmbeddedMonospacedFont", use_embedded_monospaced_font);
|
||||
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
||||
break;
|
||||
}
|
||||
case CoinControlFeatures:
|
||||
fCoinControlFeatures = value.toBool();
|
||||
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
#include <qt/guiconstants.h>
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QFont>
|
||||
|
||||
#include <assert.h>
|
||||
#include <variant>
|
||||
|
||||
struct bilingual_str;
|
||||
namespace interfaces {
|
||||
|
@ -76,6 +78,13 @@ public:
|
|||
OptionIDRowCount,
|
||||
};
|
||||
|
||||
enum class FontChoiceAbstract {
|
||||
EmbeddedFont,
|
||||
BestSystemFont,
|
||||
};
|
||||
typedef std::variant<FontChoiceAbstract, QFont> FontChoice;
|
||||
static inline const FontChoice UseBestSystemFont{FontChoiceAbstract::BestSystemFont};
|
||||
|
||||
bool Init(bilingual_str& error);
|
||||
void Reset();
|
||||
|
||||
|
@ -120,7 +129,7 @@ private:
|
|||
QString language;
|
||||
BitcoinUnit m_display_bitcoin_unit;
|
||||
QString strThirdPartyTxUrls;
|
||||
bool m_use_embedded_monospaced_font;
|
||||
FontChoice m_font_money;
|
||||
bool fCoinControlFeatures;
|
||||
bool m_sub_fee_from_amount;
|
||||
bool m_enable_psbt_controls;
|
||||
|
|
Loading…
Add table
Reference in a new issue