Qt: Don't use a static QFont

This commit is contained in:
Vicki Pfau 2021-01-26 02:14:53 -08:00
parent 40c3fc63cc
commit 6154ed91cb
11 changed files with 12 additions and 14 deletions

View File

@ -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;

View File

@ -31,7 +31,7 @@ AssetTile::AssetTile(QWidget* parent)
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);

View File

@ -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 {

View File

@ -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);

View File

@ -57,7 +57,7 @@ public:
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 @@ private:
QThreadPool m_workerThreads;
qint64 m_nextJob = 1;
static QFont s_monospace;
QFont m_monospace;
NoIntroDB* m_db = nullptr;
};

View File

@ -1594,7 +1594,7 @@ IOViewer::IOViewer(std::shared_ptr<CoreController> controller, QWidget* parent)
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);

View File

@ -28,7 +28,7 @@ using namespace QGBA;
MemoryModel::MemoryModel(QWidget* parent)
: QAbstractScrollArea(parent)
{
m_font = GBAApp::monospaceFont();
m_font = GBAApp::app()->monospaceFont();
#ifdef Q_OS_MAC
m_font.setPointSize(12);
#else

View File

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

View File

@ -33,7 +33,7 @@ ObjView::ObjView(std::shared_ptr<CoreController> controller, QWidget* parent)
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);

View File

@ -47,7 +47,7 @@ PaletteView::PaletteView(std::shared_ptr<CoreController> controller, QWidget* pa
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);

View File

@ -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 = GBAApp::monospaceFont();
const QFont font = GBAApp::app()->monospaceFont();
for (const auto& reg : names) {
QLabel* value = new QLabel;
value->setTextInteractionFlags(Qt::TextSelectableByMouse);