aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-02-21 20:58:19 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-02-21 21:01:42 +0200
commit67f26319a0ca7e34e3db17d9330133622a40de09 (patch)
tree8555ad07630e5ffd2e296bc60bce6761b8a399b3
parent22e0114d055b0ac6cdc47af2968b5dc742ba055a (diff)
downloadbitcoin-67f26319a0ca7e34e3db17d9330133622a40de09.tar.xz
gui: Add monospaced font settings
-rw-r--r--src/qt/forms/optionsdialog.ui100
-rw-r--r--src/qt/optionsdialog.cpp15
-rw-r--r--src/qt/optionsmodel.cpp13
-rw-r--r--src/qt/optionsmodel.h4
-rw-r--r--src/qt/overviewpage.cpp3
5 files changed, 134 insertions, 1 deletions
diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui
index 8181cc47e2..6d279540e9 100644
--- a/src/qt/forms/optionsdialog.ui
+++ b/src/qt/forms/optionsdialog.ui
@@ -706,6 +706,106 @@
</layout>
</item>
<item>
+ <widget class="QGroupBox" name="font_groupBox">
+ <property name="title">
+ <string>Monospaced font in the Overview tab:</string>
+ </property>
+ <layout class="QVBoxLayout" name="font_verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="embeddedFont_horizontalLayout">
+ <item>
+ <widget class="QRadioButton" name="embeddedFont_radioButton">
+ <property name="text">
+ <string>embedded &quot;%1&quot;</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="embeddedFont_horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="embeddedFont_verticalLayout">
+ <item>
+ <widget class="QLabel" name="embeddedFont_label_1">
+ <property name="text">
+ <string>111.11111111 BTC</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="embeddedFont_label_9">
+ <property name="text">
+ <string>909.09090909 BTC</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="Line" name="font_line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="systemFont_horizontalLayout">
+ <item>
+ <widget class="QRadioButton" name="systemFont_radioButton">
+ <property name="text">
+ <string>closest matching &quot;%1&quot;</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="systemFont_horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="systemFont_verticalLayout">
+ <item>
+ <widget class="QLabel" name="systemFont_label_1">
+ <property name="text">
+ <string>111.11111111 BTC</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="systemFont_label_9">
+ <property name="text">
+ <string>909.09090909 BTC</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer_Display">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index 7b8d7871ec..e6b9488344 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -144,6 +144,20 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
ui->minimizeToTray->setEnabled(false);
}
+ QFont embedded_font{GUIUtil::fixedPitchFont(true)};
+ ui->embeddedFont_radioButton->setText(ui->embeddedFont_radioButton->text().arg(QFontInfo(embedded_font).family()));
+ embedded_font.setWeight(QFont::Bold);
+ ui->embeddedFont_label_1->setFont(embedded_font);
+ ui->embeddedFont_label_9->setFont(embedded_font);
+
+ QFont system_font{GUIUtil::fixedPitchFont(false)};
+ ui->systemFont_radioButton->setText(ui->systemFont_radioButton->text().arg(QFontInfo(system_font).family()));
+ system_font.setWeight(QFont::Bold);
+ ui->systemFont_label_1->setFont(system_font);
+ ui->systemFont_label_9->setFont(system_font);
+ // Checking the embeddedFont_radioButton automatically unchecks the systemFont_radioButton.
+ ui->systemFont_radioButton->setChecked(true);
+
GUIUtil::handleCloseWindowShortcut(this);
}
@@ -246,6 +260,7 @@ 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)
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 1e0391a35c..d51a5b06ff 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -163,6 +163,12 @@ void OptionsModel::Init(bool resetSettings)
addOverriddenOption("-lang");
language = settings.value("language").toString();
+
+ if (!settings.contains("UseEmbeddedMonospacedFont")) {
+ settings.setValue("UseEmbeddedMonospacedFont", "true");
+ }
+ m_use_embedded_monospaced_font = settings.value("UseEmbeddedMonospacedFont").toBool();
+ Q_EMIT useEmbeddedMonospacedFontChanged(m_use_embedded_monospaced_font);
}
/** Helper function to copy contents from one QSettings to another.
@@ -326,6 +332,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return strThirdPartyTxUrls;
case Language:
return settings.value("language");
+ case UseEmbeddedMonospacedFont:
+ return m_use_embedded_monospaced_font;
case CoinControlFeatures:
return fCoinControlFeatures;
case Prune:
@@ -453,6 +461,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
setRestartRequired(true);
}
break;
+ case UseEmbeddedMonospacedFont:
+ m_use_embedded_monospaced_font = value.toBool();
+ settings.setValue("UseEmbeddedMonospacedFont", m_use_embedded_monospaced_font);
+ Q_EMIT useEmbeddedMonospacedFontChanged(m_use_embedded_monospaced_font);
+ break;
case CoinControlFeatures:
fCoinControlFeatures = value.toBool();
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index f7171951a1..4d012a9b8f 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -59,6 +59,7 @@ public:
DisplayUnit, // BitcoinUnits::Unit
ThirdPartyTxUrls, // QString
Language, // QString
+ UseEmbeddedMonospacedFont, // bool
CoinControlFeatures, // bool
ThreadsScriptVerif, // int
Prune, // bool
@@ -84,6 +85,7 @@ public:
bool getMinimizeOnClose() const { return fMinimizeOnClose; }
int getDisplayUnit() const { return nDisplayUnit; }
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
+ bool getUseEmbeddedMonospacedFont() const { return m_use_embedded_monospaced_font; }
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
@@ -107,6 +109,7 @@ private:
QString language;
int nDisplayUnit;
QString strThirdPartyTxUrls;
+ bool m_use_embedded_monospaced_font;
bool fCoinControlFeatures;
/* settings that were overridden by command-line */
QString strOverriddenByCommandLine;
@@ -120,6 +123,7 @@ Q_SIGNALS:
void displayUnitChanged(int unit);
void coinControlFeaturesChanged(bool);
void showTrayIconChanged(bool);
+ void useEmbeddedMonospacedFontChanged(bool);
};
#endif // BITCOIN_QT_OPTIONSMODEL_H
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
index 3a8f7af1bf..7f12b1d2b5 100644
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -258,7 +258,8 @@ void OverviewPage::setClientModel(ClientModel *model)
connect(model, &ClientModel::alertsChanged, this, &OverviewPage::updateAlerts);
updateAlerts(model->getStatusBarWarnings());
- setMonospacedFont(false);
+ connect(model->getOptionsModel(), &OptionsModel::useEmbeddedMonospacedFontChanged, this, &OverviewPage::setMonospacedFont);
+ setMonospacedFont(model->getOptionsModel()->getUseEmbeddedMonospacedFont());
}
}