all repos — mgba @ 71379aac66f002e8bc87bc3bc936fbfc4b688b27

mGBA Game Boy Advance Emulator

Qt: Unify monospace font usage
Vicki Pfau vi@endrift.com
Wed, 16 Dec 2020 18:15:54 -0800
commit

71379aac66f002e8bc87bc3bc936fbfc4b688b27

parent

c4123a238685d644b20e11aee4fec72427e0c9f4

M CHANGESCHANGES

@@ -113,6 +113,7 @@ - Qt: Add copy button to GB printer dialog

- Qt: Window title updates can be disabled (closes mgba.io/i/1912) - Qt: Redo OpenGL context thread handling (fixes mgba.io/i/1724) - Qt: Discard additional frame draws if waiting fails + - Qt: Unify monospace font usage - SDL: Fall back to sw blit if OpenGL init fails - Util: Reset vector size on deinit - VFS: Change semantics of VFile.sync on mapped files (fixes mgba.io/i/1730)
M src/platform/qt/AssetInfo.cppsrc/platform/qt/AssetInfo.cpp

@@ -5,7 +5,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "AssetInfo.h" -#include <QFontDatabase> +#include "GBAApp.h" + #include <QHBoxLayout> using namespace QGBA;

@@ -19,7 +20,7 @@ void AssetInfo::addCustomProperty(const QString& id, const QString& visibleName) {

QHBoxLayout* newLayout = new QHBoxLayout; newLayout->addWidget(new QLabel(visibleName)); QLabel* value = new QLabel; - value->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); + value->setFont(GBAApp::monospaceFont()); value->setAlignment(Qt::AlignRight); newLayout->addWidget(value); m_customProperties[id] = value;

@@ -37,4 +38,4 @@ }

int AssetInfo::customLocation(const QString&) { return layout()->count(); -}+}
M src/platform/qt/AssetTile.cppsrc/platform/qt/AssetTile.cpp

@@ -8,7 +8,6 @@

#include "CoreController.h" #include "GBAApp.h" -#include <QFontDatabase> #include <QHBoxLayout> #include <mgba/core/interface.h>

@@ -32,7 +31,7 @@ m_ui.color->setSize(50);

connect(m_ui.preview, &Swatch::indexPressed, this, &AssetTile::selectColor); - const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); + const QFont font = GBAApp::monospaceFont(); m_ui.tileId->setFont(font); m_ui.paletteId->setFont(font);
M src/platform/qt/CheatsModel.cppsrc/platform/qt/CheatsModel.cpp

@@ -5,6 +5,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "CheatsModel.h" +#include "GBAApp.h" #include "LogController.h" #include "VFileDevice.h"

@@ -19,8 +20,7 @@ CheatsModel::CheatsModel(mCheatDevice* device, QObject* parent)

: QAbstractItemModel(parent) , m_device(device) { - m_font.setFamily("Source Code Pro"); - m_font.setStyleHint(QFont::Monospace); + m_font = GBAApp::monospaceFont(); } QVariant CheatsModel::data(const QModelIndex& index, int role) const {
M src/platform/qt/GBAApp.cppsrc/platform/qt/GBAApp.cpp

@@ -16,6 +16,7 @@ #include "Window.h"

#include <QFileInfo> #include <QFileOpenEvent> +#include <QFontDatabase> #include <QIcon> #include <mgba-util/socket.h>

@@ -35,11 +36,14 @@ static GBAApp* g_app = nullptr;

mLOG_DEFINE_CATEGORY(QT, "Qt", "platform.qt"); +QFont GBAApp::s_monospace; + GBAApp::GBAApp(int& argc, char* argv[], ConfigController* config) : QApplication(argc, argv) , m_configController(config) { g_app = this; + s_monospace = QFontDatabase::systemFont(QFontDatabase::FixedFont); #ifdef BUILD_SDL SDL_Init(SDL_INIT_NOPARACHUTE);
M src/platform/qt/GBAApp.hsrc/platform/qt/GBAApp.h

@@ -7,6 +7,7 @@ #pragma once

#include <QApplication> #include <QFileDialog> +#include <QFont> #include <QList> #include <QMap> #include <QMultiMap>

@@ -55,6 +56,8 @@ GBAApp(int& argc, char* argv[], ConfigController*);

static GBAApp* app(); static QString dataDir(); + + static QFont monospaceFont() { return s_monospace; } QList<Window*> windows() { return m_windows; } Window* newWindow();

@@ -110,6 +113,8 @@ QMap<qint64, WorkerJob*> m_workerJobs;

QMultiMap<qint64, QMetaObject::Connection> m_workerJobCallbacks; QThreadPool m_workerThreads; qint64 m_nextJob = 1; + + static QFont s_monospace; NoIntroDB* m_db = nullptr; };
M src/platform/qt/IOViewer.cppsrc/platform/qt/IOViewer.cpp

@@ -6,9 +6,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "IOViewer.h" #include "CoreController.h" +#include "GBAApp.h" #include <QComboBox> -#include <QFontDatabase> #include <QGridLayout> #include <QSpinBox>

@@ -1037,7 +1037,7 @@ }

m_ui.regSelect->addItem("0x0400" + QString("%1: %2").arg(i << 1, 4, 16, QChar('0')).toUpper().arg(reg), i << 1); } - const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); + const QFont font = GBAApp::monospaceFont(); m_ui.regValue->setFont(font); connect(m_ui.buttonBox, &QDialogButtonBox::clicked, this, &IOViewer::buttonPressed);
M src/platform/qt/MapView.cppsrc/platform/qt/MapView.cpp

@@ -25,7 +25,6 @@

#include <QAction> #include <QButtonGroup> #include <QClipboard> -#include <QFontDatabase> #include <QMouseEvent> #include <QRadioButton> #include <QTimer>
M src/platform/qt/MemoryModel.cppsrc/platform/qt/MemoryModel.cpp

@@ -27,8 +27,7 @@

MemoryModel::MemoryModel(QWidget* parent) : QAbstractScrollArea(parent) { - m_font.setFamily("Source Code Pro"); - m_font.setStyleHint(QFont::Monospace); + m_font = GBAApp::monospaceFont(); #ifdef Q_OS_MAC m_font.setPointSize(12); #else
M src/platform/qt/MessagePainter.cppsrc/platform/qt/MessagePainter.cpp

@@ -5,9 +5,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "MessagePainter.h" -#include <QPainter> +#include "GBAApp.h" -#include <QDebug> +#include <QPainter> #include <mgba/gba/interface.h>

@@ -16,8 +16,7 @@

MessagePainter::MessagePainter(QObject* parent) : QObject(parent) { - m_messageFont.setFamily("Source Code Pro"); - m_messageFont.setStyleHint(QFont::Monospace); + m_messageFont = GBAApp::monospaceFont(); m_messageFont.setPixelSize(13); connect(&m_messageTimer, &QTimer::timeout, this, &MessagePainter::clearMessage); m_messageTimer.setSingleShot(true);
M src/platform/qt/ObjView.cppsrc/platform/qt/ObjView.cpp

@@ -10,7 +10,6 @@ #include "GBAApp.h"

#include <QAction> #include <QClipboard> -#include <QFontDatabase> #include <QListWidgetItem> #include <QTimer>

@@ -34,7 +33,7 @@ {

m_ui.setupUi(this); m_ui.tile->setController(controller); - const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); + const QFont font = GBAApp::monospaceFont(); m_ui.x->setFont(font); m_ui.y->setFont(font);
M src/platform/qt/PaletteView.cppsrc/platform/qt/PaletteView.cpp

@@ -11,7 +11,6 @@ #include "LogController.h"

#include "VFileDevice.h" #include <QFileDialog> -#include <QFontDatabase> #include <mgba/core/core.h> #ifdef M_CORE_GBA

@@ -48,7 +47,7 @@ m_ui.selected->setSize(64);

m_ui.selected->setDimensions(QSize(1, 1)); updatePalette(); - const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); + const QFont font = GBAApp::monospaceFont(); m_ui.hexcode->setFont(font); m_ui.value->setFont(font);
M src/platform/qt/RegisterView.cppsrc/platform/qt/RegisterView.cpp

@@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "RegisterView.h" #include "CoreController.h" +#include "GBAApp.h" #ifdef M_CORE_GBA #include <mgba/internal/arm/arm.h>

@@ -14,7 +15,6 @@ #ifdef M_CORE_GB

#include <mgba/internal/sm83/sm83.h> #endif -#include <QFontDatabase> #include <QFormLayout> #include <QLabel>

@@ -74,7 +74,7 @@ }

void RegisterView::addRegisters(const QStringList& names) { QFormLayout* form = static_cast<QFormLayout*>(layout()); - const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); + const QFont font = GBAApp::monospaceFont(); for (const auto& reg : names) { QLabel* value = new QLabel; value->setTextInteractionFlags(Qt::TextSelectableByMouse);
M src/platform/qt/TileView.cppsrc/platform/qt/TileView.cpp

@@ -10,7 +10,6 @@ #include "GBAApp.h"

#include <QAction> #include <QClipboard> -#include <QFontDatabase> #include <QTimer> #ifdef M_CORE_GB