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/theme_manager.cpp b/cockatrice/src/interface/theme_manager.cpp index d60d53589..7fe48a34b 100644 --- a/cockatrice/src/interface/theme_manager.cpp +++ b/cockatrice/src/interface/theme_manager.cpp @@ -127,9 +127,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)) @@ -534,15 +534,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,14 +663,6 @@ QFont ThemeManager::appFont(AppFont::Role role) const return qApp->font(); } -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 37a70f755..b93752ce5 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; @@ -152,11 +152,6 @@ public: /** @brief Resolves an application font role: the theme's stored [Fonts] * value when present, otherwise the application font. */ QFont appFont(AppFont::Role role) 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);