Qt: Unify monospace font usage

This commit is contained in:
Vicki Pfau 2020-12-16 18:15:54 -08:00
parent c4123a2386
commit 71379aac66
14 changed files with 27 additions and 23 deletions

View File

@ -113,6 +113,7 @@ Misc:
- 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)

View File

@ -5,7 +5,8 @@
* 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 @@ void AssetInfo::setCustomProperty(const QString& id, const QVariant& value) {
int AssetInfo::customLocation(const QString&) {
return layout()->count();
}
}

View File

@ -8,7 +8,6 @@
#include "CoreController.h"
#include "GBAApp.h"
#include <QFontDatabase>
#include <QHBoxLayout>
#include <mgba/core/interface.h>
@ -32,7 +31,7 @@ AssetTile::AssetTile(QWidget* parent)
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);

View File

@ -5,6 +5,7 @@
* 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 {

View File

@ -16,6 +16,7 @@
#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);

View File

@ -7,6 +7,7 @@
#include <QApplication>
#include <QFileDialog>
#include <QFont>
#include <QList>
#include <QMap>
#include <QMultiMap>
@ -56,6 +57,8 @@ public:
static QString dataDir();
static QFont monospaceFont() { return s_monospace; }
QList<Window*> windows() { return m_windows; }
Window* newWindow();
@ -111,6 +114,8 @@ private:
QThreadPool m_workerThreads;
qint64 m_nextJob = 1;
static QFont s_monospace;
NoIntroDB* m_db = nullptr;
};

View File

@ -6,9 +6,9 @@
#include "IOViewer.h"
#include "CoreController.h"
#include "GBAApp.h"
#include <QComboBox>
#include <QFontDatabase>
#include <QGridLayout>
#include <QSpinBox>
@ -1037,7 +1037,7 @@ IOViewer::IOViewer(std::shared_ptr<CoreController> controller, QWidget* parent)
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);

View File

@ -25,7 +25,6 @@
#include <QAction>
#include <QButtonGroup>
#include <QClipboard>
#include <QFontDatabase>
#include <QMouseEvent>
#include <QRadioButton>
#include <QTimer>

View File

@ -27,8 +27,7 @@ using namespace QGBA;
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

View File

@ -5,9 +5,9 @@
* 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 @@ using namespace QGBA;
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);

View File

@ -10,7 +10,6 @@
#include <QAction>
#include <QClipboard>
#include <QFontDatabase>
#include <QListWidgetItem>
#include <QTimer>
@ -34,7 +33,7 @@ ObjView::ObjView(std::shared_ptr<CoreController> controller, QWidget* parent)
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);

View File

@ -11,7 +11,6 @@
#include "VFileDevice.h"
#include <QFileDialog>
#include <QFontDatabase>
#include <mgba/core/core.h>
#ifdef M_CORE_GBA
@ -48,7 +47,7 @@ PaletteView::PaletteView(std::shared_ptr<CoreController> controller, QWidget* pa
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);

View File

@ -6,6 +6,7 @@
#include "RegisterView.h"
#include "CoreController.h"
#include "GBAApp.h"
#ifdef M_CORE_GBA
#include <mgba/internal/arm/arm.h>
@ -14,7 +15,6 @@
#include <mgba/internal/sm83/sm83.h>
#endif
#include <QFontDatabase>
#include <QFormLayout>
#include <QLabel>
@ -74,7 +74,7 @@ RegisterView::RegisterView(std::shared_ptr<CoreController> controller, QWidget*
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);

View File

@ -10,7 +10,6 @@
#include <QAction>
#include <QClipboard>
#include <QFontDatabase>
#include <QTimer>
#ifdef M_CORE_GB