[Fonts] Migrate DeckList and InterfaceDefault surfaces to theme roles (#7539)

* [Fonts] Migrate DeckList and InterfaceDefault surfaces to theme roles

* [Fonts] Drop unused lambda captures in font-refresh handlers

* [Fonts] Fix pixel sizes and game overlay fonts from review

- Set the sizes the stylesheets carried with setPixelSize() rather than
  setPointSize(): home buttons (34), banner (24), home group box (20),
  the placeholder labels (14), the analytics drag handle (10), the EDHREC
  navigation buttons (24), the user info popup (11/14/11/10/11) and the
  game overlays (14/16/12). Points at 96 DPI were ~33% larger.
- The drag/total counters and tally columns keep the monospace family the
  stylesheets set, so digit widths stop changing as counts tick and
  white-space: pre stays aligned.
- applyDeckListFont() drops the cached tally rows before re-measuring, so
  previewing a larger DeckList font no longer leaves the tally clipped.
- Tally labels and the constructor/fontsChanged pairs in the shared-deck
  preview, quick setup, analytics panel, home box and public decks build
  their font once in a local lambda instead of twice.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-11-04 07:57:54 +01:00 • committed by GitHub
parent 396196b762
commit 3bcdfc3793
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 387 additions and 79 deletions

View file

@ -1,6 +1,9 @@
#include "edhrec_commander_api_response_bracket_navigation_widget.h"
#include "../../interface/theme_manager.h"
#include <QChar>
#include <QFont>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
@ -25,7 +28,7 @@ EdhrecCommanderApiResponseBracketNavigationWidget::EdhrecCommanderApiResponseBra
QString label = option.isEmpty() ? "All" : option.at(0).toUpper() + option.mid(1);
QPushButton *optionButton = new QPushButton(label, this);
optionButton->setMinimumHeight(84);
optionButton->setStyleSheet("font-size: 24px");
optionButton->setStyleSheet(QString());
gameChangerButtons[option] = optionButton;
layout->addWidget(optionButton, 2, i);
connect(optionButton, &QPushButton::clicked, this, [=, this]() {
@ -35,6 +38,10 @@ EdhrecCommanderApiResponseBracketNavigationWidget::EdhrecCommanderApiResponseBra
});
}
applyInterfaceDefaultFont();
connect(themeManager, &ThemeManager::fontsChanged, this,
&EdhrecCommanderApiResponseBracketNavigationWidget::applyInterfaceDefaultFont);
updateOptionButtonSelection(gameChangerButtons, "");
retranslateUi();
@ -94,8 +101,18 @@ void EdhrecCommanderApiResponseBracketNavigationWidget::updateOptionButtonSelect
const QString &selectedKey)
{
for (auto it = buttons.begin(); it != buttons.end(); ++it) {
it.value()->setStyleSheet(it.key() == selectedKey
? "background-color: lightblue; font-weight: bold; font-size: 24px;"
: "font-size: 24px");
const bool selected = (it.key() == selectedKey);
it.value()->setStyleSheet(selected ? QStringLiteral("background-color: lightblue;") : QString());
QFont buttonFont = themeManager->appFont(AppFont::InterfaceDefault);
buttonFont.setPixelSize(24);
buttonFont.setWeight(selected ? QFont::Bold : QFont::Normal);
it.value()->setFont(buttonFont);
}
}
void EdhrecCommanderApiResponseBracketNavigationWidget::applyInterfaceDefaultFont()
{
// Family comes from the InterfaceDefault theme role; the 24px size stays
// caller-side and the selected button keeps its bold emphasis.
updateOptionButtonSelection(gameChangerButtons, selectedGameChanger);
}

View file

@ -37,6 +37,9 @@ private:
QMap<QString, QPushButton *> gameChangerButtons;
void updateOptionButtonSelection(QMap<QString, QPushButton *> &buttons, const QString &selectedKey);
private slots:
void applyInterfaceDefaultFont();
};
#endif // COCKATRICE_EDHREC_COMMANDER_API_RESPONSE_BRACKET_NAVIGATION_WIDGET_H

View file

@ -1,6 +1,9 @@
#include "edhrec_commander_api_response_budget_navigation_widget.h"
#include "../../interface/theme_manager.h"
#include <QChar>
#include <QFont>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
@ -25,7 +28,7 @@ EdhrecCommanderApiResponseBudgetNavigationWidget::EdhrecCommanderApiResponseBudg
QString label = option.isEmpty() ? "Any" : option.at(0).toUpper() + option.mid(1);
QPushButton *btn = new QPushButton(label, this);
btn->setMinimumHeight(84);
btn->setStyleSheet("font-size: 24px");
btn->setStyleSheet(QString());
budgetButtons[option] = btn;
layout->addWidget(btn, 4, i);
connect(btn, &QPushButton::clicked, this, [=, this]() {
@ -35,6 +38,10 @@ EdhrecCommanderApiResponseBudgetNavigationWidget::EdhrecCommanderApiResponseBudg
});
}
applyInterfaceDefaultFont();
connect(themeManager, &ThemeManager::fontsChanged, this,
&EdhrecCommanderApiResponseBudgetNavigationWidget::applyInterfaceDefaultFont);
updateOptionButtonSelection(budgetButtons, "");
retranslateUi();
@ -96,8 +103,18 @@ void EdhrecCommanderApiResponseBudgetNavigationWidget::updateOptionButtonSelecti
const QString &selectedKey)
{
for (auto it = buttons.begin(); it != buttons.end(); ++it) {
it.value()->setStyleSheet(it.key() == selectedKey
? "background-color: lightblue; font-weight: bold; font-size: 24px;"
: "font-size: 24px");
const bool selected = (it.key() == selectedKey);
it.value()->setStyleSheet(selected ? QStringLiteral("background-color: lightblue;") : QString());
QFont buttonFont = themeManager->appFont(AppFont::InterfaceDefault);
buttonFont.setPixelSize(24);
buttonFont.setWeight(selected ? QFont::Bold : QFont::Normal);
it.value()->setFont(buttonFont);
}
}
void EdhrecCommanderApiResponseBudgetNavigationWidget::applyInterfaceDefaultFont()
{
// Family comes from the InterfaceDefault theme role; the 24px size stays
// caller-side and the selected button keeps its bold emphasis.
updateOptionButtonSelection(budgetButtons, selectedBudget);
}

View file

@ -37,6 +37,9 @@ private:
QMap<QString, QPushButton *> budgetButtons;
void updateOptionButtonSelection(QMap<QString, QPushButton *> &buttons, const QString &selectedKey);
private slots:
void applyInterfaceDefaultFont();
};
#endif // COCKATRICE_EDHREC_COMMANDER_API_RESPONSE_BUDGET_NAVIGATION_WIDGET_H

View file

@ -1,9 +1,11 @@
#include "edhrec_commander_api_response_navigation_widget.h"
#include "../../interface/theme_manager.h"
#include "../../tab_edhrec_main.h"
#include "edhrec_commander_api_response_bracket_navigation_widget.h"
#include "edhrec_commander_api_response_budget_navigation_widget.h"
#include <QFont>
#include <QGridLayout>
#include <QObject>
#include <QPushButton>
@ -30,10 +32,14 @@ EdhrecCommanderApiResponseNavigationWidget::EdhrecCommanderApiResponseNavigation
comboPushButton = new QPushButton(this);
comboPushButton->setMinimumHeight(84);
comboPushButton->setStyleSheet("font-size: 24px");
comboPushButton->setStyleSheet(QString());
averageDeckPushButton = new QPushButton(this);
averageDeckPushButton->setMinimumHeight(84);
averageDeckPushButton->setStyleSheet("font-size: 24px");
averageDeckPushButton->setStyleSheet(QString());
applyInterfaceDefaultFont();
connect(themeManager, &ThemeManager::fontsChanged, this,
&EdhrecCommanderApiResponseNavigationWidget::applyInterfaceDefaultFont);
layout->addWidget(comboPushButton, 0, 0, 1, 1);
layout->addWidget(averageDeckPushButton, 0, 1, 1, 1);
@ -61,6 +67,15 @@ void EdhrecCommanderApiResponseNavigationWidget::retranslateUi()
averageDeckPushButton->setText(tr("Average Deck"));
}
void EdhrecCommanderApiResponseNavigationWidget::applyInterfaceDefaultFont()
{
// Family comes from the InterfaceDefault theme role; the 24px size stays caller-side.
QFont navFont = themeManager->appFont(AppFont::InterfaceDefault);
navFont.setPixelSize(24);
comboPushButton->setFont(navFont);
averageDeckPushButton->setFont(navFont);
}
QString EdhrecCommanderApiResponseNavigationWidget::addNavigationOptionsToUrl(QString baseUrl)
{
if (!bracketNavigationWidget->getSelectedGameChanger().isEmpty()) {

View file

@ -35,6 +35,9 @@ public slots:
signals:
void requestUrl(QString url);
private slots:
void applyInterfaceDefaultFont();
private:
QGridLayout *layout;

View file

@ -6,6 +6,7 @@
#include "tab_developer.h"
#include "../interface/theme_manager.h"
#include "libcockatrice/protocol/pb/response.pb.h"
#include <QAbstractItemView>
@ -155,7 +156,8 @@ void TabDeveloper::appendSeparatorRow(const QString &sectionTitle)
const int row = statsTable->rowCount();
statsTable->insertRow(row);
auto *labelItem = new QTableWidgetItem(sectionTitle);
auto font = labelItem->font();
// Family comes from the InterfaceDefault theme role; bold stays caller-side.
QFont font = themeManager->appFont(AppFont::InterfaceDefault);
font.setBold(true);
labelItem->setFont(font);
labelItem->setFlags(labelItem->flags() & ~Qt::ItemIsSelectable);

View file

@ -4,6 +4,7 @@
#include "../../deck_loader/deck_loader.h"
#include "../cards/card_size_widget.h"
#include "../general/layout_containers/flow_widget.h"
#include "../interface/theme_manager.h"
#include "../visual_deck_storage/deck_preview/deck_preview_color_identity_filter_widget.h"
#include "../visual_deck_storage/deck_preview/public_deck_preview_widget.h"
#include "../visual_deck_storage/remote_public_decks_model.h"
@ -45,7 +46,12 @@ TabPublicDecks::TabPublicDecks(TabSupervisor *_tabSupervisor, AbstractClient *_c
cardSize = SettingsCache::instance().cardsDisplay().getVisualDeckStorageCardSize();
titleLabel = new QLabel(tr("Public decks of %1").arg(userName.toHtmlEscaped()), this);
titleLabel->setFont(QtUtils::boldFont(titleLabel->font()));
// Family comes from the InterfaceDefault theme role; bold stays caller-side.
auto applyTitleFont = [this]() {
titleLabel->setFont(QtUtils::boldFont(themeManager->appFont(AppFont::InterfaceDefault)));
};
applyTitleFont();
connect(themeManager, &ThemeManager::fontsChanged, this, applyTitleFont);
auto *headerLayout = new QHBoxLayout;
headerLayout->addWidget(titleLabel);