all repos — mgba @ 6154ed91cb48a8ad25b9986ea03553f1e27351c1

mGBA Game Boy Advance Emulator

Qt: Don't use a static QFont
Vicki Pfau vi@endrift.com
Tue, 26 Jan 2021 02:14:53 -0800
commit

6154ed91cb48a8ad25b9986ea03553f1e27351c1

parent

40c3fc63ccad3ab59b6b37399cd6fe8ea1de3f3e

M src/platform/qt/AssetInfo.cppsrc/platform/qt/AssetInfo.cpp

@@ -20,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(GBAApp::monospaceFont()); + value->setFont(GBAApp::app()->monospaceFont()); value->setAlignment(Qt::AlignRight); newLayout->addWidget(value); m_customProperties[id] = value;
M src/platform/qt/AssetTile.cppsrc/platform/qt/AssetTile.cpp

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

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

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

: QAbstractItemModel(parent) , m_device(device) { - m_font = GBAApp::monospaceFont(); + m_font = GBAApp::app()->monospaceFont(); } QVariant CheatsModel::data(const QModelIndex& index, int role) const {
M src/platform/qt/GBAApp.cppsrc/platform/qt/GBAApp.cpp

@@ -36,14 +36,12 @@ 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) + , m_monospace(QFontDatabase::systemFont(QFontDatabase::FixedFont)) { 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

@@ -57,7 +57,7 @@ static GBAApp* app();

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

@@ -114,7 +114,7 @@ QMultiMap<qint64, QMetaObject::Connection> m_workerJobCallbacks;

QThreadPool m_workerThreads; qint64 m_nextJob = 1; - static QFont s_monospace; + QFont m_monospace; NoIntroDB* m_db = nullptr; };
M src/platform/qt/IOViewer.cppsrc/platform/qt/IOViewer.cpp

@@ -1594,7 +1594,7 @@ }

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

@@ -28,7 +28,7 @@

MemoryModel::MemoryModel(QWidget* parent) : QAbstractScrollArea(parent) { - m_font = GBAApp::monospaceFont(); + m_font = GBAApp::app()->monospaceFont(); #ifdef Q_OS_MAC m_font.setPointSize(12); #else
M src/platform/qt/MessagePainter.cppsrc/platform/qt/MessagePainter.cpp

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

MessagePainter::MessagePainter(QObject* parent) : QObject(parent) { - m_messageFont = GBAApp::monospaceFont(); + m_messageFont = GBAApp::app()->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

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

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

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

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

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

void RegisterView::addRegisters(const QStringList& names) { QFormLayout* form = static_cast<QFormLayout*>(layout()); - const QFont font = GBAApp::monospaceFont(); + const QFont font = GBAApp::app()->monospaceFont(); for (const auto& reg : names) { QLabel* value = new QLabel; value->setTextInteractionFlags(Qt::TextSelectableByMouse);