diff --git a/cockatrice/src/game_graphics/board/abstract_graphics_item.cpp b/cockatrice/src/game_graphics/board/abstract_graphics_item.cpp index 3a740aa98..e847e878d 100644 --- a/cockatrice/src/game_graphics/board/abstract_graphics_item.cpp +++ b/cockatrice/src/game_graphics/board/abstract_graphics_item.cpp @@ -22,7 +22,7 @@ void AbstractGraphicsItem::paintNumberEllipse(int number, painter->save(); QString numStr = QString::number(number); - QFont font = themeManager->cardTextFont(); + QFont font = themeManager->appFont(AppFont::CardText); font.setPixelSize(fontSize); font.setWeight(QFont::Bold); diff --git a/cockatrice/src/game_graphics/board/counter_general.cpp b/cockatrice/src/game_graphics/board/counter_general.cpp index 23618e6bf..b06a98e95 100644 --- a/cockatrice/src/game_graphics/board/counter_general.cpp +++ b/cockatrice/src/game_graphics/board/counter_general.cpp @@ -42,7 +42,7 @@ void GeneralCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * / painter->drawPixmap(QPoint(0, 0), pixmap); if (value) { - QFont f = themeManager->cardTextFont(); + QFont f = themeManager->appFont(AppFont::CardText); f.setPixelSize(qMax((int)(radius * scaleFactor), 10)); f.setWeight(QFont::Bold); painter->setPen(Qt::black); diff --git a/cockatrice/src/game_graphics/game_view.cpp b/cockatrice/src/game_graphics/game_view.cpp index 2f8af3e1b..346f515e4 100644 --- a/cockatrice/src/game_graphics/game_view.cpp +++ b/cockatrice/src/game_graphics/game_view.cpp @@ -26,21 +26,6 @@ #include #include -namespace -{ -QFont deckOverlayFont(int pixelSize, bool bold) -{ - // The drag/total counters and the tally columns are in-game overlays, not - // deck list text: keep the monospace family the stylesheets used to set so - // digit widths stay stable as counts tick and `white-space: pre` lines up. - QFont font(QStringLiteral("monospace")); - font.setStyleHint(QFont::Monospace); - font.setPixelSize(pixelSize); - font.setBold(bold); - return font; -} -} // namespace - // QRubberBand calls raise() in showEvent() and changeEvent() to stay on top of siblings. // This subclass disables that behavior so dragCountLabel can appear above it. class SelectionRubberBand : public QRubberBand @@ -123,21 +108,34 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par void GameView::applyDeckListFont() { - dragCountLabel->setFont(deckOverlayFont(14, true)); - totalCountLabel->setFont(deckOverlayFont(16, true)); - tallyContainer->setFont(deckOverlayFont(12, false)); + // 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(tallyLayout->itemAt(i)->widget())) { - // Count column (odd positions) keeps the bold emphasis. - const bool count = i % 2 == 1; - label->setFont(deckOverlayFont(count ? 14 : 12, count)); + 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); } } - - // The container keeps the size computed from the previous fonts, so force - // rebuildTallyLabels() to re-measure it instead of reusing cachedTallyRows. - cachedTallyRows.clear(); - updateTotalSelectionCount(); } void GameView::resizeEvent(QResizeEvent *event) @@ -268,13 +266,18 @@ QSize GameView::rebuildTallyLabels(const QList &entries) for (const TallyRow &entry : entries) { auto *nameLabel = new QLabel(entry.name, tallyContainer); nameLabel->setStyleSheet(nameStyle); - nameLabel->setFont(deckOverlayFont(12, false)); + 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); - countLabel->setFont(deckOverlayFont(14, true)); + 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); diff --git a/cockatrice/src/game_graphics/player/player_target.cpp b/cockatrice/src/game_graphics/player/player_target.cpp index 60c99524a..ac947b164 100644 --- a/cockatrice/src/game_graphics/player/player_target.cpp +++ b/cockatrice/src/game_graphics/player/player_target.cpp @@ -77,7 +77,7 @@ void PlayerCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /* QRectF translatedRect = path.controlPointRect(); QSize translatedSize = translatedRect.size().toSize(); - QFont font = themeManager->cardTextFont(); + QFont font = themeManager->appFont(AppFont::CardText); font.setWeight(QFont::Bold); font.setPixelSize(qMax(qRound(translatedSize.height() / 1.3), 9)); painter->setFont(font); diff --git a/cockatrice/src/interface/palette_editor/font_grid_widget.cpp b/cockatrice/src/interface/palette_editor/font_grid_widget.cpp index 1dd8345bb..c3841b95f 100644 --- a/cockatrice/src/interface/palette_editor/font_grid_widget.cpp +++ b/cockatrice/src/interface/palette_editor/font_grid_widget.cpp @@ -76,11 +76,9 @@ void FontGridWidget::loadFonts(const FontConfig &cfg) auto role = static_cast(fontEnum.value(i)); const FontRow &row = fontRows[role]; - // Roles absent from the file resolve to the startup font, not to the - // live preview: appFont() would return the previewed config, so Reset - // and a first load would both show the edited font instead of the - // theme's real default. - const QFont font = cfg.fonts.value(role, themeManager->defaultAppFont(role)); + // Roles absent from the file resolve to the theme's effective font, so + // unset roles visibly show the system default instead of blanks. + const QFont font = cfg.fonts.value(role, themeManager->appFont(role)); row.familyCombo->setCurrentFont(font); int size = font.pointSize(); diff --git a/cockatrice/src/interface/palette_editor/palette_editor_dialog.cpp b/cockatrice/src/interface/palette_editor/palette_editor_dialog.cpp index 36027f7d0..c3412bd09 100644 --- a/cockatrice/src/interface/palette_editor/palette_editor_dialog.cpp +++ b/cockatrice/src/interface/palette_editor/palette_editor_dialog.cpp @@ -392,10 +392,6 @@ void PaletteEditorDialog::onReset() { workingConfig[loadedScheme] = savedConfig[loadedScheme]; paletteGrid->loadPalette(savedConfig[loadedScheme]); - // Restore the live theme before re-reading the grid: loadFonts resolves - // unset roles, and the preview has currentFonts pointing at the edited - // config until the theme is reloaded. - themeManager->reloadCurrentTheme(); fontGrid->loadFonts(savedFontConfig); seedAccentFromScheme(loadedScheme); } diff --git a/cockatrice/src/interface/palette_editor/quick_setup_panel.cpp b/cockatrice/src/interface/palette_editor/quick_setup_panel.cpp index 00eac3253..612dcc2cf 100644 --- a/cockatrice/src/interface/palette_editor/quick_setup_panel.cpp +++ b/cockatrice/src/interface/palette_editor/quick_setup_panel.cpp @@ -30,14 +30,16 @@ QuickSetupPanel::QuickSetupPanel(QWidget *parent) : QWidget(parent) labelLow = new QLabel(this); labelHigh = new QLabel(this); // Family comes from the InterfaceDefault theme role; the *0.82 size stays caller-side. - auto applySmallFont = [this]() { - QFont small = themeManager->appFont(AppFont::InterfaceDefault); - small.setPointSizeF(small.pointSizeF() * 0.82); - labelLow->setFont(small); - labelHigh->setFont(small); - }; - applySmallFont(); - connect(themeManager, &ThemeManager::fontsChanged, this, applySmallFont); + QFont small = themeManager->appFont(AppFont::InterfaceDefault); + small.setPointSizeF(small.pointSizeF() * 0.82); + labelLow->setFont(small); + labelHigh->setFont(small); + connect(themeManager, &ThemeManager::fontsChanged, this, [this]() { + QFont refreshedSmall = themeManager->appFont(AppFont::InterfaceDefault); + refreshedSmall.setPointSizeF(refreshedSmall.pointSizeF() * 0.82); + labelLow->setFont(refreshedSmall); + labelHigh->setFont(refreshedSmall); + }); QPalette dimmed = labelLow->palette(); dimmed.setColor(QPalette::WindowText, qApp->palette().color(QPalette::Mid)); labelLow->setPalette(dimmed); diff --git a/cockatrice/src/interface/theme_manager.cpp b/cockatrice/src/interface/theme_manager.cpp index 922174eb8..f9d5a67c4 100644 --- a/cockatrice/src/interface/theme_manager.cpp +++ b/cockatrice/src/interface/theme_manager.cpp @@ -128,9 +128,9 @@ static QString usableDefaultStyle(const QString &style) ThemeManager::ThemeManager(QObject *parent) : QObject(parent) { defaultStyleName = usableDefaultStyle(qApp->style()->objectName()); - // Capture the untouched application palette and font before any theme is - // applied. + // Capture the untouched application palette before any theme is applied. defaultPalette = qApp->palette(); + // Capture the untouched application font before any theme font is applied. defaultFont = qApp->font(); ensureThemeDirectoryExists(); #if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) @@ -535,15 +535,18 @@ void ThemeManager::previewFonts(const FontConfig &cfg) { currentFonts = cfg; - // QApplication::setFont already sends a font change to every widget, so a - // repolish pass is not needed for fonts (unlike the palette path). const auto it = cfg.fonts.constFind(AppFont::InterfaceDefault); if (it != cfg.fonts.constEnd()) { qApp->setFont(it.value()); - } else { - // A config without InterfaceDefault means "no override": restore the - // startup font instead of leaving the last preview applied. - qApp->setFont(defaultFont); + + // Repolish every widget immediately so the preview applies without + // waiting for natural expose events, mirroring applyStyleAndPalette. + QStyle *style = qApp->style(); + for (QWidget *widget : qApp->allWidgets()) { + style->unpolish(widget); + style->polish(widget); + widget->update(); + } } emit fontsChanged(); @@ -660,41 +663,23 @@ QFont ThemeManager::appFont(AppFont::Role role) const // present: chat logs rendered monospace (matching the report dialogs), // card text from a serif basis, everything else from the app font. if (role == AppFont::ChatLog) { - // ChatView never set a font before the theme role existed, so an unset - // ChatLog must keep resolving to the application font. The report - // dialogs that used to hardcode monospace ask for it explicitly - // (report_utils::reportLogFont) instead of through this fallback. - return qApp->font(); + QFont monoFont(QStringLiteral("monospace")); + monoFont.setStyleHint(QFont::Monospace); + const int systemPointSize = QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize(); + if (systemPointSize > 0) { + monoFont.setPointSize(systemPointSize); + } + return monoFont; } - // No per-role scaling: an unset role resolves to the application font, so - // with no fonts.toml present the result is identical to before. The counter - // painters that used to hardcode Serif ask for it through cardTextFont(). + if (role == AppFont::CardText) { + return QFont(QStringLiteral("Serif")); + } + + // No per-role scaling: every other unset role resolves to the application + // font, so with no fonts.toml present the result is identical to before. return qApp->font(); } -bool ThemeManager::hasAppFont(AppFont::Role role) const -{ - return currentFonts.fonts.contains(role); -} - -QFont ThemeManager::cardTextFont() const -{ - if (hasAppFont(AppFont::CardText)) { - return appFont(AppFont::CardText); - } - QFont serifFont(QStringLiteral("Serif")); - serifFont.setStyleHint(QFont::Serif); - return serifFont; -} - -QFont ThemeManager::defaultAppFont(AppFont::Role /*role*/) const -{ - // No per-role scaling and no preview: an unset role resolves to the font - // captured at startup, which is what the theme falls back to once the - // editor closes. - return defaultFont; -} - void ThemeManager::themeChangedSlot() { QString themeName = SettingsCache::instance().getThemeName(); diff --git a/cockatrice/src/interface/theme_manager.h b/cockatrice/src/interface/theme_manager.h index 3120e1cf6..8a0e6919b 100644 --- a/cockatrice/src/interface/theme_manager.h +++ b/cockatrice/src/interface/theme_manager.h @@ -49,8 +49,8 @@ private: // switching away from a custom palette restores the original colours. QPalette defaultPalette; // Pristine application font captured at startup, before any theme font is - // applied. Restored when a theme (or a preview) supplies no InterfaceDefault - // font, so switching away from a themed font cannot leave it behind. + // applied. Used to restore the original font when a theme supplies none, + // mirroring defaultPalette above. QFont defaultFont; QString currentThemePath; std::array brushes; @@ -154,16 +154,6 @@ public: * ChatLog, serif basis for CardText, the application font for the * remaining roles). */ QFont appFont(AppFont::Role role) const; - /** @brief Whether the active theme defines this role in fonts.toml. */ - bool hasAppFont(AppFont::Role role) const; - /** @brief The CardText role with its historical Serif fallback. Used by the - * counter painters, which were Serif before the role existed. */ - QFont cardTextFont() const; - /** @brief Resolves an application font role against the startup font only, - * ignoring any previewed config in currentFonts. Editors that show - * "what this role resolves to" must use this, because appFont() - * reflects a live preview while the editor is open. */ - QFont defaultAppFont(AppFont::Role role) const; QBrush &getBgBrush(Role zone); QBrush getExtraBgBrush(Role zone, int zoneId = 0); diff --git a/cockatrice/src/interface/widgets/deck_analytics/resizable_panel.cpp b/cockatrice/src/interface/widgets/deck_analytics/resizable_panel.cpp index 602326535..c197c5e1e 100644 --- a/cockatrice/src/interface/widgets/deck_analytics/resizable_panel.cpp +++ b/cockatrice/src/interface/widgets/deck_analytics/resizable_panel.cpp @@ -104,13 +104,14 @@ ResizablePanel::ResizablePanel(const QString &_typeId, AbstractAnalyticsPanelWid "QPushButton:hover { background: %4; }") .arg(mid.name(), dark.name(), placeholderText.name(), midLight.name())); // Family comes from the InterfaceDefault theme role; the 10px size stays caller-side. - auto applyDragFont = [this]() { - QFont dragFont = themeManager->appFont(AppFont::InterfaceDefault); - dragFont.setPixelSize(10); - dragButton->setFont(dragFont); - }; - applyDragFont(); - connect(themeManager, &ThemeManager::fontsChanged, this, applyDragFont); + QFont dragFont = themeManager->appFont(AppFont::InterfaceDefault); + dragFont.setPointSize(10); + dragButton->setFont(dragFont); + connect(themeManager, &ThemeManager::fontsChanged, this, [this]() { + QFont refreshedFont = themeManager->appFont(AppFont::InterfaceDefault); + refreshedFont.setPointSize(10); + dragButton->setFont(refreshedFont); + }); resizeHandle->setStyleSheet(QString("QWidget { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, " "stop:0 %1, stop:1 %2); }") diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_my_reports.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_my_reports.cpp index a7387a068..a259b6a56 100644 --- a/cockatrice/src/interface/widgets/dialogs/dlg_my_reports.cpp +++ b/cockatrice/src/interface/widgets/dialogs/dlg_my_reports.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -126,7 +127,14 @@ DlgMyReports::DlgMyReports(AbstractClient *_client, QWidget *parent) void DlgMyReports::applyChatLogFont() { - chatLogEdit->setFont(report_utils::reportLogFont()); + // Family comes from the ChatLog theme role; size stays caller-side as before. + QFont monoFont = themeManager->appFont(AppFont::ChatLog); + monoFont.setStyleHint(QFont::Monospace); + const int systemPointSize = QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize(); + if (systemPointSize > 0) { + monoFont.setPointSize(systemPointSize); + } + chatLogEdit->setFont(monoFont); } void DlgMyReports::refreshList() diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_report_user.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_report_user.cpp index 5b0937177..5cdeb22a1 100644 --- a/cockatrice/src/interface/widgets/dialogs/dlg_report_user.cpp +++ b/cockatrice/src/interface/widgets/dialogs/dlg_report_user.cpp @@ -1,13 +1,13 @@ #include "dlg_report_user.h" #include "../interface/theme_manager.h" -#include "../utility/report_utils.h" #include "abstract_client.h" #include "libcockatrice/protocol/pb/response.pb.h" #include #include #include +#include #include #include #include @@ -125,7 +125,14 @@ DlgReportUser::DlgReportUser(AbstractClient *_client, void DlgReportUser::applyChatLogFont() { - chatLogEdit->setFont(report_utils::reportLogFont()); + // Family comes from the ChatLog theme role; size stays caller-side as before. + QFont monoFont = themeManager->appFont(AppFont::ChatLog); + monoFont.setStyleHint(QFont::Monospace); + const int systemPointSize = QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize(); + if (systemPointSize > 0) { + monoFont.setPointSize(systemPointSize); + } + chatLogEdit->setFont(monoFont); } void DlgReportUser::actSubmit() diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_shared_decks_preview.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_shared_decks_preview.cpp index d5485fdbe..717fbf024 100644 --- a/cockatrice/src/interface/widgets/dialogs/dlg_shared_decks_preview.cpp +++ b/cockatrice/src/interface/widgets/dialogs/dlg_shared_decks_preview.cpp @@ -36,14 +36,16 @@ DlgSharedDecksPreview::DlgSharedDecksPreview(QWidget *parent, auto *titleLabel = new QLabel(tr("Share: %1").arg((shareName.isEmpty() ? tr("Untitled") : shareName).toHtmlEscaped()), this); // Family comes from the InterfaceDefault theme role; the +2 size and bold stay caller-side. - auto applyTitleFont = [titleLabel]() { - QFont titleFont = themeManager->appFont(AppFont::InterfaceDefault); - titleFont.setBold(true); - titleFont.setPointSize(titleFont.pointSize() + 2); - titleLabel->setFont(titleFont); - }; - applyTitleFont(); - connect(themeManager, &ThemeManager::fontsChanged, this, applyTitleFont); + QFont titleFont = themeManager->appFont(AppFont::InterfaceDefault); + titleFont.setBold(true); + titleFont.setPointSize(titleFont.pointSize() + 2); + titleLabel->setFont(titleFont); + connect(themeManager, &ThemeManager::fontsChanged, this, [titleLabel]() { + QFont refreshedFont = themeManager->appFont(AppFont::InterfaceDefault); + refreshedFont.setBold(true); + refreshedFont.setPointSize(refreshedFont.pointSize() + 2); + titleLabel->setFont(refreshedFont); + }); mainLayout->addWidget(titleLabel); if (!serverText.isEmpty()) { diff --git a/cockatrice/src/interface/widgets/general/display/banner_widget.cpp b/cockatrice/src/interface/widgets/general/display/banner_widget.cpp index 5cb62db0f..b4b23aacc 100644 --- a/cockatrice/src/interface/widgets/general/display/banner_widget.cpp +++ b/cockatrice/src/interface/widgets/general/display/banner_widget.cpp @@ -65,7 +65,7 @@ void BannerWidget::applyInterfaceDefaultFont() // Family comes from the InterfaceDefault theme role; the 24px size and // bold weight previously carried by the stylesheet stay caller-side. QFont bannerFont = themeManager->appFont(AppFont::InterfaceDefault); - bannerFont.setPixelSize(24); + bannerFont.setPointSize(24); bannerFont.setWeight(QFont::Bold); bannerLabel->setFont(bannerFont); } diff --git a/cockatrice/src/interface/widgets/general/home_styled_button.cpp b/cockatrice/src/interface/widgets/general/home_styled_button.cpp index 9c31d3815..bbd1f8c04 100644 --- a/cockatrice/src/interface/widgets/general/home_styled_button.cpp +++ b/cockatrice/src/interface/widgets/general/home_styled_button.cpp @@ -33,7 +33,7 @@ void HomeStyledButton::applyInterfaceDefaultFont() // Family comes from the InterfaceDefault theme role; the 34px size and // bold weight previously carried by the stylesheet stay caller-side. QFont buttonFont = themeManager->appFont(AppFont::InterfaceDefault); - buttonFont.setPixelSize(34); + buttonFont.setPointSize(34); buttonFont.setWeight(QFont::Bold); setFont(buttonFont); } diff --git a/cockatrice/src/interface/widgets/general/home_widget.cpp b/cockatrice/src/interface/widgets/general/home_widget.cpp index 2b4847466..311c94f0b 100644 --- a/cockatrice/src/interface/widgets/general/home_widget.cpp +++ b/cockatrice/src/interface/widgets/general/home_widget.cpp @@ -274,13 +274,14 @@ QGroupBox *HomeWidget::createButtons() } )"); // Family comes from the InterfaceDefault theme role; the 20px size stays caller-side. - auto applyBoxFont = [box]() { - QFont boxFont = themeManager->appFont(AppFont::InterfaceDefault); - boxFont.setPixelSize(20); - box->setFont(boxFont); - }; - applyBoxFont(); - connect(themeManager, &ThemeManager::fontsChanged, this, applyBoxFont); + QFont boxFont = themeManager->appFont(AppFont::InterfaceDefault); + boxFont.setPointSize(20); + box->setFont(boxFont); + connect(themeManager, &ThemeManager::fontsChanged, this, [box]() { + QFont refreshedFont = themeManager->appFont(AppFont::InterfaceDefault); + refreshedFont.setPointSize(20); + box->setFont(refreshedFont); + }); box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QVBoxLayout *boxLayout = new QVBoxLayout; boxLayout->setAlignment(Qt::AlignHCenter); diff --git a/cockatrice/src/interface/widgets/printing_selector/printing_selector_placeholder_widget.cpp b/cockatrice/src/interface/widgets/printing_selector/printing_selector_placeholder_widget.cpp index 225c3e21d..d9d261be5 100644 --- a/cockatrice/src/interface/widgets/printing_selector/printing_selector_placeholder_widget.cpp +++ b/cockatrice/src/interface/widgets/printing_selector/printing_selector_placeholder_widget.cpp @@ -55,6 +55,6 @@ void PrintingSelectorPlaceholderWidget::applyInterfaceDefaultFont() { // Family comes from the InterfaceDefault theme role; the 14px size stays caller-side. QFont placeholderFont = themeManager->appFont(AppFont::InterfaceDefault); - placeholderFont.setPixelSize(14); + placeholderFont.setPointSize(14); textLabel->setFont(placeholderFont); } \ No newline at end of file diff --git a/cockatrice/src/interface/widgets/server/user/user_info_popup.cpp b/cockatrice/src/interface/widgets/server/user/user_info_popup.cpp index 18ac313ee..ca22f1d12 100644 --- a/cockatrice/src/interface/widgets/server/user/user_info_popup.cpp +++ b/cockatrice/src/interface/widgets/server/user/user_info_popup.cpp @@ -482,7 +482,7 @@ void UserInfoPopup::applyTheme() gamesLabel->setStyleSheet(QStringLiteral("color:%1; background:transparent;").arg(colorStr(theme.subText))); QFont gamesLabelFont = themeManager->appFont(AppFont::InterfaceDefault); - gamesLabelFont.setPixelSize(11); + gamesLabelFont.setPointSize(11); gamesLabelFont.setWeight(QFont::Bold); gamesLabel->setFont(gamesLabelFont); @@ -490,13 +490,13 @@ void UserInfoPopup::applyTheme() "QPushButton:hover{color:%2;}") .arg(colorStr(theme.subText), colorStr(theme.text))); QFont refreshFont = themeManager->appFont(AppFont::InterfaceDefault); - refreshFont.setPixelSize(14); + refreshFont.setPointSize(14); refreshBtn->setFont(refreshFont); gamesStatus->setStyleSheet( QStringLiteral("color:%1; padding:10px; background:transparent;").arg(colorStr(theme.statusText))); QFont statusFont = themeManager->appFont(AppFont::InterfaceDefault); - statusFont.setPixelSize(11); + statusFont.setPointSize(11); gamesStatus->setFont(statusFont); gamesView->setStyleSheet(QStringLiteral("QListView{background:%1;border:none;}" @@ -509,7 +509,7 @@ void UserInfoPopup::applyTheme() "QPushButton:hover{color:%3;background:%4;}") .arg(colorStr(theme.closeBg), colorStr(theme.subText), colorStr(theme.text), colorStr(theme.closeHover))); QFont closeFont = themeManager->appFont(AppFont::InterfaceDefault); - closeFont.setPixelSize(10); + closeFont.setPointSize(10); closeBtn->setFont(closeFont); header->update(); @@ -534,7 +534,7 @@ static QPushButton *makeBtn(const QString &label, const QString &tip, QWidget *p colorStr(t.text), colorStr(t.buttonPressed), colorStr(t.buttonDisabled))); // Family comes from the InterfaceDefault theme role; the 11px size stays caller-side. QFont btnFont = themeManager->appFont(AppFont::InterfaceDefault); - btnFont.setPixelSize(11); + btnFont.setPointSize(11); b->setFont(btnFont); return b; } diff --git a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/cards/edhrec_api_response_card_details_display_widget.cpp b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/cards/edhrec_api_response_card_details_display_widget.cpp index 630e0b85a..73a322d18 100644 --- a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/cards/edhrec_api_response_card_details_display_widget.cpp +++ b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/cards/edhrec_api_response_card_details_display_widget.cpp @@ -101,10 +101,9 @@ void EdhrecApiResponseCardDetailsDisplayWidget::actRequestPageNavigation() void EdhrecApiResponseCardDetailsDisplayWidget::applyCardTextFont() { // Family comes from the CardText theme role; the 20px size and bold - // weight previously carried by the stylesheet stay caller-side. Pixel - // size, not point size: the stylesheet said 20px, and 20pt is ~27px. + // weight previously carried by the stylesheet stay caller-side. QFont cardFont = themeManager->appFont(AppFont::CardText); - cardFont.setPixelSize(20); + cardFont.setPointSize(20); cardFont.setWeight(QFont::Bold); nameLabel->setFont(cardFont); } diff --git a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_api_response_commander_details_display_widget.cpp b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_api_response_commander_details_display_widget.cpp index 56b9d74cb..68852c7bb 100644 --- a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_api_response_commander_details_display_widget.cpp +++ b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_api_response_commander_details_display_widget.cpp @@ -96,16 +96,15 @@ void EdhrecCommanderResponseCommanderDetailsDisplayWidget::retranslateUi() void EdhrecCommanderResponseCommanderDetailsDisplayWidget::applyCardTextFont() { - // Family comes from the CardText theme role; the sizes and the bold - // weight previously carried by the stylesheets stay caller-side. Pixel - // sizes, not point sizes: the stylesheets said 28px and 16px. + // Family comes from the CardText theme role; the point sizes and the + // bold weight previously carried by the stylesheets stay caller-side. QFont nameFont = themeManager->appFont(AppFont::CardText); - nameFont.setPixelSize(28); + nameFont.setPointSize(28); nameFont.setWeight(QFont::Bold); commanderName->setFont(nameFont); QFont detailsFont = themeManager->appFont(AppFont::CardText); - detailsFont.setPixelSize(16); + detailsFont.setPointSize(16); label->setFont(detailsFont); salt->setFont(detailsFont); } diff --git a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_bracket_navigation_widget.cpp b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_bracket_navigation_widget.cpp index 749476619..9324bcef7 100644 --- a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_bracket_navigation_widget.cpp +++ b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_bracket_navigation_widget.cpp @@ -104,7 +104,7 @@ void EdhrecCommanderApiResponseBracketNavigationWidget::updateOptionButtonSelect 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.setPointSize(24); buttonFont.setWeight(selected ? QFont::Bold : QFont::Normal); it.value()->setFont(buttonFont); } diff --git a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_budget_navigation_widget.cpp b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_budget_navigation_widget.cpp index 27cd1c51f..b31394549 100644 --- a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_budget_navigation_widget.cpp +++ b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_budget_navigation_widget.cpp @@ -106,7 +106,7 @@ void EdhrecCommanderApiResponseBudgetNavigationWidget::updateOptionButtonSelecti 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.setPointSize(24); buttonFont.setWeight(selected ? QFont::Bold : QFont::Normal); it.value()->setFont(buttonFont); } diff --git a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_navigation_widget.cpp b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_navigation_widget.cpp index 304db6336..320dfe05b 100644 --- a/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_navigation_widget.cpp +++ b/cockatrice/src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_navigation_widget.cpp @@ -78,7 +78,7 @@ 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); + navFont.setPointSize(24); comboPushButton->setFont(navFont); averageDeckPushButton->setFont(navFont); } diff --git a/cockatrice/src/interface/widgets/tabs/tab_public_decks.cpp b/cockatrice/src/interface/widgets/tabs/tab_public_decks.cpp index fc5ef8bd8..1b5ee277c 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_public_decks.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_public_decks.cpp @@ -46,13 +46,14 @@ TabPublicDecks::TabPublicDecks(TabSupervisor *_tabSupervisor, AbstractClient *_c titleLabel = new QLabel(tr("Public decks of %1").arg(userName.toHtmlEscaped()), this); // Family comes from the InterfaceDefault theme role; bold stays caller-side. - auto applyTitleFont = [this]() { - QFont titleFont = themeManager->appFont(AppFont::InterfaceDefault); - titleFont.setBold(true); - titleLabel->setFont(titleFont); - }; - applyTitleFont(); - connect(themeManager, &ThemeManager::fontsChanged, this, applyTitleFont); + QFont titleFont = themeManager->appFont(AppFont::InterfaceDefault); + titleFont.setBold(true); + titleLabel->setFont(titleFont); + connect(themeManager, &ThemeManager::fontsChanged, this, [this]() { + QFont refreshedFont = themeManager->appFont(AppFont::InterfaceDefault); + refreshedFont.setBold(true); + titleLabel->setFont(refreshedFont); + }); auto *headerLayout = new QHBoxLayout; headerLayout->addWidget(titleLabel); diff --git a/cockatrice/src/interface/widgets/tabs/tab_report.cpp b/cockatrice/src/interface/widgets/tabs/tab_report.cpp index 1df5bc078..bcb6e7191 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_report.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_report.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -274,7 +275,14 @@ TabReport::TabReport(TabSupervisor *_tabSupervisor, AbstractClient *_client) : T void TabReport::applyChatLogFont() { - chatLogEdit->setFont(report_utils::reportLogFont()); + // Family comes from the ChatLog theme role; size stays caller-side as before. + QFont monoFont = themeManager->appFont(AppFont::ChatLog); + monoFont.setStyleHint(QFont::Monospace); + const int systemPointSize = QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize(); + if (systemPointSize > 0) { + monoFont.setPointSize(systemPointSize); + } + chatLogEdit->setFont(monoFont); } void TabReport::retranslateUi() diff --git a/cockatrice/src/interface/widgets/utility/report_utils.cpp b/cockatrice/src/interface/widgets/utility/report_utils.cpp index df2400b14..d7fc083c6 100644 --- a/cockatrice/src/interface/widgets/utility/report_utils.cpp +++ b/cockatrice/src/interface/widgets/utility/report_utils.cpp @@ -1,6 +1,5 @@ #include "report_utils.h" -#include "../../theme_manager.h" #include "libcockatrice/protocol/pb/serverinfo_report.pb.h" #include @@ -8,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -21,20 +19,6 @@ namespace report_utils { -QFont reportLogFont() -{ - if (themeManager->hasAppFont(AppFont::ChatLog)) { - return themeManager->appFont(AppFont::ChatLog); - } - QFont monoFont(QStringLiteral("monospace")); - monoFont.setStyleHint(QFont::Monospace); - const int systemPointSize = QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize(); - if (systemPointSize > 0) { - monoFont.setPointSize(systemPointSize); - } - return monoFont; -} - namespace { QColor reportStatusColor(const QString &status) diff --git a/cockatrice/src/interface/widgets/utility/report_utils.h b/cockatrice/src/interface/widgets/utility/report_utils.h index 32cc19eac..679989486 100644 --- a/cockatrice/src/interface/widgets/utility/report_utils.h +++ b/cockatrice/src/interface/widgets/utility/report_utils.h @@ -1,7 +1,6 @@ #ifndef REPORT_UTILS_H #define REPORT_UTILS_H -#include #include #include @@ -12,12 +11,6 @@ class ServerInfo_Report; namespace report_utils { -/** @brief Font for the report chat-log views: the theme's ChatLog role when it - * sets one, otherwise the monospace font these views used before the - * role existed. Shared by the three report surfaces so they cannot - * drift apart. */ -QFont reportLogFont(); - QString formatReportCategory(const QString &category); QString formatReportTime(qint64 secondsSinceEpoch); diff --git a/cockatrice/src/interface/widgets/visual_deck_editor/visual_deck_editor_placeholder_widget.cpp b/cockatrice/src/interface/widgets/visual_deck_editor/visual_deck_editor_placeholder_widget.cpp index d3c087bc6..8269c4802 100644 --- a/cockatrice/src/interface/widgets/visual_deck_editor/visual_deck_editor_placeholder_widget.cpp +++ b/cockatrice/src/interface/widgets/visual_deck_editor/visual_deck_editor_placeholder_widget.cpp @@ -53,6 +53,6 @@ void VisualDeckEditorPlaceholderWidget::applyInterfaceDefaultFont() { // Family comes from the InterfaceDefault theme role; the 14px size stays caller-side. QFont placeholderFont = themeManager->appFont(AppFont::InterfaceDefault); - placeholderFont.setPixelSize(14); + placeholderFont.setPointSize(14); textLabel->setFont(placeholderFont); } \ No newline at end of file