From 22e0114d055b0ac6cdc47af2968b5dc742ba055a Mon Sep 17 00:00:00 2001
From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Date: Sun, 21 Feb 2021 20:30:01 +0200
Subject: [PATCH] qt: Choose monospaced font in C++ code rather in `*.ui` file
Setting the "Monospace" font family in a `*.ui` file does not work on
macOS, at least on Big Sur with Qt 5.15 (neither via the "font" property
nor via the "styleSheet" property). Qt chooses the ".AppleSystemUIFont"
instead of ".AppleSystemUIFontMonospaced".
This change makes macOS choose the correct monospaced font.
---
src/qt/forms/overviewpage.ui | 56 ------------------------------------
src/qt/overviewpage.cpp | 16 +++++++++++
src/qt/overviewpage.h | 1 +
3 files changed, 17 insertions(+), 56 deletions(-)
diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui
index ee9d4a113c..b82143e1ba 100644
--- a/src/qt/forms/overviewpage.ui
+++ b/src/qt/forms/overviewpage.ui
@@ -116,13 +116,6 @@
-
-
-
- Monospace
- 75
- true
-
-
IBeamCursor
@@ -142,13 +135,6 @@
-
-
-
- Monospace
- 75
- true
-
-
IBeamCursor
@@ -168,13 +154,6 @@
-
-
-
- Monospace
- 75
- true
-
-
IBeamCursor
@@ -227,13 +206,6 @@
-
-
-
- Monospace
- 75
- true
-
-
IBeamCursor
@@ -273,13 +245,6 @@
-
-
-
- Monospace
- 75
- true
-
-
IBeamCursor
@@ -299,13 +264,6 @@
-
-
-
- Monospace
- 75
- true
-
-
IBeamCursor
@@ -342,13 +300,6 @@
-
-
-
- Monospace
- 75
- true
-
-
IBeamCursor
@@ -368,13 +319,6 @@
-
-
-
- Monospace
- 75
- true
-
-
IBeamCursor
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
index bc542a0833..3a8f7af1bf 100644
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -257,6 +257,8 @@ void OverviewPage::setClientModel(ClientModel *model)
// Show warning, for example if this is a prerelease version
connect(model, &ClientModel::alertsChanged, this, &OverviewPage::updateAlerts);
updateAlerts(model->getStatusBarWarnings());
+
+ setMonospacedFont(false);
}
}
@@ -321,3 +323,17 @@ void OverviewPage::showOutOfSyncWarning(bool fShow)
ui->labelWalletStatus->setVisible(fShow);
ui->labelTransactionsStatus->setVisible(fShow);
}
+
+void OverviewPage::setMonospacedFont(bool use_embedded_font)
+{
+ QFont f = GUIUtil::fixedPitchFont(use_embedded_font);
+ f.setWeight(QFont::Bold);
+ ui->labelBalance->setFont(f);
+ ui->labelUnconfirmed->setFont(f);
+ ui->labelImmature->setFont(f);
+ ui->labelTotal->setFont(f);
+ ui->labelWatchAvailable->setFont(f);
+ ui->labelWatchPending->setFont(f);
+ ui->labelWatchImmature->setFont(f);
+ ui->labelWatchTotal->setFont(f);
+}
diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h
index 578ef601fb..5158c81678 100644
--- a/src/qt/overviewpage.h
+++ b/src/qt/overviewpage.h
@@ -61,6 +61,7 @@ private Q_SLOTS:
void updateAlerts(const QString &warnings);
void updateWatchOnlyLabels(bool showWatchOnly);
void handleOutOfSyncWarningClicks();
+ void setMonospacedFont(bool use_embedded_font);
};
#endif // BITCOIN_QT_OVERVIEWPAGE_H