GUI: Move "embedded font or not" decision into new OptionsModel::getFontForMoney method

This commit is contained in:
Luke Dashjr 2021-12-02 01:10:05 +00:00
parent bbbf89a9de
commit f2dfde80b8
4 changed files with 15 additions and 10 deletions

View File

@ -219,7 +219,7 @@ bool OptionsModel::Init(bilingual_str& error)
settings.setValue("UseEmbeddedMonospacedFont", "true"); settings.setValue("UseEmbeddedMonospacedFont", "true");
} }
m_use_embedded_monospaced_font = settings.value("UseEmbeddedMonospacedFont").toBool(); m_use_embedded_monospaced_font = settings.value("UseEmbeddedMonospacedFont").toBool();
Q_EMIT useEmbeddedMonospacedFontChanged(m_use_embedded_monospaced_font); Q_EMIT fontForMoneyChanged(getFontForMoney());
m_mask_values = settings.value("mask_values", false).toBool(); m_mask_values = settings.value("mask_values", false).toBool();
@ -454,6 +454,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);
return f;
}
bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::string& suffix) bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::string& suffix)
{ {
auto changed = [&] { return value.isValid() && value != getOption(option, suffix); }; auto changed = [&] { return value.isValid() && value != getOption(option, suffix); };
@ -589,7 +596,7 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
case UseEmbeddedMonospacedFont: case UseEmbeddedMonospacedFont:
m_use_embedded_monospaced_font = value.toBool(); m_use_embedded_monospaced_font = value.toBool();
settings.setValue("UseEmbeddedMonospacedFont", m_use_embedded_monospaced_font); settings.setValue("UseEmbeddedMonospacedFont", m_use_embedded_monospaced_font);
Q_EMIT useEmbeddedMonospacedFontChanged(m_use_embedded_monospaced_font); Q_EMIT fontForMoneyChanged(getFontForMoney());
break; break;
case CoinControlFeatures: case CoinControlFeatures:
fCoinControlFeatures = value.toBool(); fCoinControlFeatures = value.toBool();

View File

@ -93,7 +93,7 @@ public:
bool getMinimizeOnClose() const { return fMinimizeOnClose; } bool getMinimizeOnClose() const { return fMinimizeOnClose; }
BitcoinUnit getDisplayUnit() const { return m_display_bitcoin_unit; } BitcoinUnit getDisplayUnit() const { return m_display_bitcoin_unit; }
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; } QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
bool getUseEmbeddedMonospacedFont() const { return m_use_embedded_monospaced_font; } QFont getFontForMoney() const;
bool getCoinControlFeatures() const { return fCoinControlFeatures; } bool getCoinControlFeatures() const { return fCoinControlFeatures; }
bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; } bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
bool getEnablePSBTControls() const { return m_enable_psbt_controls; } bool getEnablePSBTControls() const { return m_enable_psbt_controls; }
@ -139,7 +139,7 @@ Q_SIGNALS:
void displayUnitChanged(BitcoinUnit unit); void displayUnitChanged(BitcoinUnit unit);
void coinControlFeaturesChanged(bool); void coinControlFeaturesChanged(bool);
void showTrayIconChanged(bool); void showTrayIconChanged(bool);
void useEmbeddedMonospacedFontChanged(bool); void fontForMoneyChanged(const QFont&);
}; };
#endif // BITCOIN_QT_OPTIONSMODEL_H #endif // BITCOIN_QT_OPTIONSMODEL_H

View File

@ -250,8 +250,8 @@ void OverviewPage::setClientModel(ClientModel *model)
connect(model, &ClientModel::alertsChanged, this, &OverviewPage::updateAlerts); connect(model, &ClientModel::alertsChanged, this, &OverviewPage::updateAlerts);
updateAlerts(model->getStatusBarWarnings()); updateAlerts(model->getStatusBarWarnings());
connect(model->getOptionsModel(), &OptionsModel::useEmbeddedMonospacedFontChanged, this, &OverviewPage::setMonospacedFont); connect(model->getOptionsModel(), &OptionsModel::fontForMoneyChanged, this, &OverviewPage::setMonospacedFont);
setMonospacedFont(model->getOptionsModel()->getUseEmbeddedMonospacedFont()); setMonospacedFont(clientModel->getOptionsModel()->getFontForMoney());
} }
} }
@ -340,10 +340,8 @@ void OverviewPage::showOutOfSyncWarning(bool fShow)
ui->labelTransactionsStatus->setVisible(fShow); ui->labelTransactionsStatus->setVisible(fShow);
} }
void OverviewPage::setMonospacedFont(bool use_embedded_font) void OverviewPage::setMonospacedFont(const QFont& f)
{ {
QFont f = GUIUtil::fixedPitchFont(use_embedded_font);
f.setWeight(QFont::Bold);
ui->labelBalance->setFont(f); ui->labelBalance->setFont(f);
ui->labelUnconfirmed->setFont(f); ui->labelUnconfirmed->setFont(f);
ui->labelImmature->setFont(f); ui->labelImmature->setFont(f);

View File

@ -65,7 +65,7 @@ private Q_SLOTS:
void handleTransactionClicked(const QModelIndex &index); void handleTransactionClicked(const QModelIndex &index);
void updateAlerts(const QString &warnings); void updateAlerts(const QString &warnings);
void updateWatchOnlyLabels(bool showWatchOnly); void updateWatchOnlyLabels(bool showWatchOnly);
void setMonospacedFont(bool use_embedded_font); void setMonospacedFont(const QFont&);
}; };
#endif // BITCOIN_QT_OVERVIEWPAGE_H #endif // BITCOIN_QT_OVERVIEWPAGE_H