aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/qt/optionsdialog.cpp16
-rw-r--r--src/qt/optionsmodel.cpp34
-rw-r--r--src/qt/optionsmodel.h5
3 files changed, 38 insertions, 17 deletions
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index 6dec4b2e42..fcc9aced09 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -198,6 +198,15 @@ void OptionsDialog::setModel(OptionsModel *_model)
setMapper();
mapper->toFirst();
+ const auto& font_for_money = _model->data(_model->index(OptionsModel::FontForMoney, 0), Qt::EditRole).value<OptionsModel::FontChoice>();
+ if (std::holds_alternative<OptionsModel::FontChoiceAbstract>(font_for_money)) {
+ ui->embeddedFont_radioButton->setChecked(font_for_money != OptionsModel::UseBestSystemFont);
+ ui->systemFont_radioButton->setChecked(font_for_money == OptionsModel::UseBestSystemFont);
+ } else {
+ ui->embeddedFont_radioButton->setChecked(false);
+ ui->systemFont_radioButton->setChecked(false);
+ }
+
updateDefaultProxyNets();
}
@@ -275,7 +284,6 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->lang, OptionsModel::Language);
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls);
- mapper->addMapping(ui->embeddedFont_radioButton, OptionsModel::UseEmbeddedMonospacedFont);
}
void OptionsDialog::setOkButtonState(bool fState)
@@ -337,6 +345,12 @@ void OptionsDialog::on_openBitcoinConfButton_clicked()
void OptionsDialog::on_okButton_clicked()
{
+ if (ui->embeddedFont_radioButton->isChecked()) {
+ model->setData(model->index(OptionsModel::FontForMoney, 0), QVariant::fromValue(OptionsModel::FontChoice{OptionsModel::FontChoiceAbstract::EmbeddedFont}));
+ } else if (ui->systemFont_radioButton->isChecked()) {
+ model->setData(model->index(OptionsModel::FontForMoney, 0), QVariant::fromValue(OptionsModel::FontChoice{OptionsModel::FontChoiceAbstract::BestSystemFont}));
+ }
+
mapper->submit();
accept();
updateDefaultProxyNets();
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index a7aea31858..ef32a11523 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -122,6 +122,18 @@ 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, ")};
+QString OptionsModel::FontChoiceToString(const OptionsModel::FontChoice& f)
+{
+ if (std::holds_alternative<FontChoiceAbstract>(f)) {
+ if (f == UseBestSystemFont) {
+ return fontchoice_str_best_system;
+ } else {
+ return fontchoice_str_embedded;
+ }
+ }
+ return fontchoice_str_custom_prefix + std::get<QFont>(f).toString();
+}
+
OptionsModel::FontChoice OptionsModel::FontChoiceFromString(const QString& s)
{
if (s == fontchoice_str_best_system) {
@@ -451,8 +463,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
return strThirdPartyTxUrls;
case Language:
return QString::fromStdString(SettingToString(setting(), ""));
- case UseEmbeddedMonospacedFont:
- return (m_font_money != UseBestSystemFont);
+ case FontForMoney:
+ return QVariant::fromValue(m_font_money);
case CoinControlFeatures:
return fCoinControlFeatures;
case EnablePSBTControls:
@@ -622,20 +634,12 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
setRestartRequired(true);
}
break;
- case UseEmbeddedMonospacedFont:
+ case FontForMoney:
{
- 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);
- settings.remove("FontForMoney");
+ const auto& new_font = value.value<FontChoice>();
+ if (m_font_money == new_font) break;
+ settings.setValue("FontForMoney", FontChoiceToString(new_font));
+ m_font_money = new_font;
Q_EMIT fontForMoneyChanged(getFontForMoney());
break;
}
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index 79928d2fa9..1984002028 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -62,7 +62,7 @@ public:
DisplayUnit, // BitcoinUnit
ThirdPartyTxUrls, // QString
Language, // QString
- UseEmbeddedMonospacedFont, // bool
+ FontForMoney, // FontChoice
CoinControlFeatures, // bool
SubFeeFromAmount, // bool
ThreadsScriptVerif, // int
@@ -138,6 +138,7 @@ private:
/* settings that were overridden by command-line */
QString strOverriddenByCommandLine;
+ static QString FontChoiceToString(const OptionsModel::FontChoice&);
static FontChoice FontChoiceFromString(const QString&);
// Add option to list of GUI options overridden through command line/config file
@@ -153,4 +154,6 @@ Q_SIGNALS:
void fontForMoneyChanged(const QFont&);
};
+Q_DECLARE_METATYPE(OptionsModel::FontChoice)
+
#endif // BITCOIN_QT_OPTIONSMODEL_H