diff options
author | João Barbosa <joao.paulo.barbosa@gmail.com> | 2021-10-06 15:06:40 +0100 |
---|---|---|
committer | João Barbosa <joao.paulo.barbosa@gmail.com> | 2021-10-07 17:01:21 +0100 |
commit | d54ec27bac388d7b84cf7b6cb4506bb0c25f2f88 (patch) | |
tree | 9974c849a4b5745b8f51dfd1a13d868a0c5e98ee /src/qt | |
parent | c0b6c96eee7c9e24b78935516225259e61cdabf7 (diff) | |
download | bitcoin-d54ec27bac388d7b84cf7b6cb4506bb0c25f2f88.tar.xz |
qt: Add helper to load font
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/bitcoin.cpp | 3 | ||||
-rw-r--r-- | src/qt/guiutil.cpp | 6 | ||||
-rw-r--r-- | src/qt/guiutil.h | 5 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 00c9fd3059..7de56a648a 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -46,7 +46,6 @@ #include <QApplication> #include <QDebug> -#include <QFontDatabase> #include <QLatin1String> #include <QLibraryInfo> #include <QLocale> @@ -492,7 +491,7 @@ int GuiMain(int argc, char* argv[]) #endif BitcoinApplication app; - QFontDatabase::addApplicationFont(":/fonts/monospace"); + GUIUtil::LoadFont(QStringLiteral(":/fonts/monospace")); /// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these // Command-line options take precedence: diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 7b1384b485..12d3a48d01 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -272,6 +272,12 @@ bool hasEntryData(const QAbstractItemView *view, int column, int role) return !selection.at(0).data(role).toString().isEmpty(); } +void LoadFont(const QString& file_name) +{ + const int id = QFontDatabase::addApplicationFont(file_name); + assert(id != -1); +} + QString getDefaultDataDirectory() { return boostPathToQString(GetDefaultDataDir()); diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 6287f95192..211f3f506d 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -114,6 +114,11 @@ namespace GUIUtil void setClipboard(const QString& str); /** + * Loads the font from the file specified by file_name, aborts if it fails. + */ + void LoadFont(const QString& file_name); + + /** * Determine default data directory for operating system. */ QString getDefaultDataDirectory(); |