[Fonts] Migrate DeckList and InterfaceDefault surfaces to theme roles

This commit is contained in:
Lukas Brübach 2026-10-16 09:47:37 +02:00
parent d4f0b75e87
commit dd15c1a5f9
45 changed files with 392 additions and 75 deletions

View file

@ -240,7 +240,8 @@ void DeckViewCardContainer::paint(QPainter *painter, const QStyleOptionGraphicsI
painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY));
painter->setPen(QColor(Qt::white));
QFont f("Serif");
// Family comes from the DeckList theme role; pixel sizes/weights unchanged.
QFont f = themeManager->appFont(AppFont::DeckList);
f.setStyleHint(QFont::Serif);
f.setPixelSize(24);
f.setWeight(QFont::Bold);
@ -292,7 +293,8 @@ QList<QPair<int, int>> DeckViewCardContainer::getRowsAndCols() const
int DeckViewCardContainer::getCardTypeTextWidth() const
{
QFont f("Serif");
// Family comes from the DeckList theme role; pixel size/weight unchanged.
QFont f = themeManager->appFont(AppFont::DeckList);
f.setStyleHint(QFont::Serif);
f.setPixelSize(16);
f.setWeight(QFont::Bold);

View file

@ -2,12 +2,14 @@
#include "../client/settings/cache_settings.h"
#include "../client/settings/shortcuts_settings.h"
#include "../interface/theme_manager.h"
#include "game_scene.h"
#include <QAction>
#include <QBrush>
#include <QColor>
#include <QEvent>
#include <QFont>
#include <QGraphicsScene>
#include <QGridLayout>
#include <QLabel>
@ -75,15 +77,14 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
rubberBand = new SelectionRubberBand(QRubberBand::Rectangle, this);
const QString baseProperties = "color: white; "
"font-family: monospace; "
"background-color: rgba(0, 0, 0, 160); "
"border-radius: 3px; "
"padding: 1px 2px; "
"white-space: pre;";
const QString dragCountLabelStyle = baseProperties + "font-size: 14px; font-weight: bold;";
const QString totalCountLabelStyle = baseProperties + "font-size: 16px; font-weight: bold;";
const QString subtypeTallyLabelStyle = baseProperties + "font-size: 12px;";
const QString dragCountLabelStyle = baseProperties;
const QString totalCountLabelStyle = baseProperties;
const QString subtypeTallyLabelStyle = baseProperties;
dragCountLabel = new QLabel(this);
dragCountLabel->setStyleSheet(dragCountLabelStyle);
@ -100,6 +101,41 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
tallyLayout->setContentsMargins(2, 2, 2, 2);
tallyLayout->setSpacing(2);
tallyContainer->hide();
applyDeckListFont();
connect(themeManager, &ThemeManager::fontsChanged, this, &GameView::applyDeckListFont);
}
void GameView::applyDeckListFont()
{
// Family comes from the DeckList theme role; the pixel sizes and bold
// weights previously carried by the stylesheets stay caller-side.
QFont dragFont = themeManager->appFont(AppFont::DeckList);
dragFont.setPointSize(14);
dragFont.setWeight(QFont::Bold);
dragCountLabel->setFont(dragFont);
QFont totalFont = themeManager->appFont(AppFont::DeckList);
totalFont.setPointSize(16);
totalFont.setWeight(QFont::Bold);
totalCountLabel->setFont(totalFont);
QFont tallyFont = themeManager->appFont(AppFont::DeckList);
tallyFont.setPointSize(12);
tallyContainer->setFont(tallyFont);
for (int i = 0; i < tallyLayout->count(); ++i) {
if (auto *label = qobject_cast<QLabel *>(tallyLayout->itemAt(i)->widget())) {
QFont labelFont = themeManager->appFont(AppFont::DeckList);
// Count column (odd positions) keeps the 14px bold emphasis.
if (i % 2 == 1) {
labelFont.setPointSize(14);
labelFont.setWeight(QFont::Bold);
} else {
labelFont.setPointSize(12);
}
label->setFont(labelFont);
}
}
}
void GameView::resizeEvent(QResizeEvent *event)
@ -219,9 +255,8 @@ QSize GameView::rebuildTallyLabels(const QList<TallyRow> &entries)
{
clearTallyLabels();
const QString nameStyle = QStringLiteral("color: white; font-size: 12px; background: transparent;");
const QString countStyle =
QStringLiteral("color: white; font-size: 14px; font-weight: bold; background: transparent;");
const QString nameStyle = QStringLiteral("color: white; background: transparent;");
const QString countStyle = QStringLiteral("color: white; background: transparent;");
int totalHeight = 0;
int maxNameWidth = 0;
@ -231,11 +266,18 @@ QSize GameView::rebuildTallyLabels(const QList<TallyRow> &entries)
for (const TallyRow &entry : entries) {
auto *nameLabel = new QLabel(entry.name, tallyContainer);
nameLabel->setStyleSheet(nameStyle);
QFont nameFont = themeManager->appFont(AppFont::DeckList);
nameFont.setPointSize(12);
nameLabel->setFont(nameFont);
nameLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
tallyLayout->addWidget(nameLabel, row, 0);
auto *countLabel = new QLabel(entry.value, tallyContainer);
countLabel->setStyleSheet(countStyle);
QFont countFont = themeManager->appFont(AppFont::DeckList);
countFont.setPointSize(14);
countFont.setWeight(QFont::Bold);
countLabel->setFont(countFont);
countLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
tallyLayout->addWidget(countLabel, row, 1);

View file

@ -50,6 +50,7 @@ private slots:
void refreshShortcuts();
void updateTotalSelectionCount(const QSize &viewSize = QSize());
void setFocusDisabled(bool disabled);
void applyDeckListFont();
public slots:
void updateSceneRect(const QRectF &rect);