mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 17:15:09 -07:00
[AppColors] Address review comments
- PaletteEditorDialog::onSave(): compare whole PaletteConfig (colors and appColors) so a change to only AccentStrong/AccentSoft writes the file; add PaletteConfig::operator==. - appColor(): derive both roles from QPalette::Highlight unconditionally. The Fusion palettes pin Accent to near-Window values, and QPalette::Accent only exists on Qt 6.6+, so keying on it made identical themes render very differently across Qt versions. - themeChangedSlot(): merge the theme default's [AppColors] into a custom palette that predates the section instead of all-or-nothing per file; hasPalette() now counts an appColors-only file as a palette. - Add Default/palette-default-light.toml so the Default theme's Light scheme keeps the classic greens instead of falling back to the OS accent. - home_widget: restore the isBuiltInTheme() half of the Automatic condition; non-built-in themes extract button colors from their own background art. - palette_grid_widget: use appEnum.value(i) for the role cast (3 sites), append appHeader to headerLabels, fix the 'Lighted' typo.
This commit is contained in:
parent
03684bf41d
commit
7549f9c2cf
7 changed files with 107 additions and 19 deletions
|
|
@ -441,14 +441,12 @@ QColor ThemeManager::appColor(AppColor::Role role) const
|
|||
return it.value();
|
||||
}
|
||||
|
||||
// QPalette::Accent was introduced in Qt 6.6; before that the nearest
|
||||
// accent is the selection highlight, which Accent defaults to when unset.
|
||||
const QColor accent = qApp->palette().color(QPalette::Active,
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||
QPalette::Accent);
|
||||
#else
|
||||
QPalette::Highlight);
|
||||
#endif
|
||||
// QPalette::Accent was introduced in Qt 6.6 and several shipped palettes
|
||||
// set it to a value barely distinguishable from Window, so it is not a
|
||||
// reliable accent source. The selection highlight is the stable accent
|
||||
// (Accent defaults to Highlight when unset), and deriving from it
|
||||
// unconditionally keeps every Qt version rendering identically.
|
||||
const QColor accent = qApp->palette().color(QPalette::Active, QPalette::Highlight);
|
||||
|
||||
if (role == AppColor::AccentSoft) {
|
||||
constexpr int SOFT_SATURATION_PERCENT = 70;
|
||||
|
|
@ -497,8 +495,19 @@ void ThemeManager::themeChangedSlot()
|
|||
|
||||
// ── Load palette: custom first, then theme default ────────────────────
|
||||
PaletteConfig palette = PaletteConfig::fromScheme(dirPath, activeScheme);
|
||||
if (!palette.hasPalette()) {
|
||||
palette = ThemeManager::loadDefaultPaletteConfig(dirPath, themeName, activeScheme);
|
||||
const PaletteConfig themeDefault = ThemeManager::loadDefaultPaletteConfig(dirPath, themeName, activeScheme);
|
||||
if (palette.hasPalette()) {
|
||||
// A custom palette written before [AppColors] existed carries no app
|
||||
// colors; merge the theme's shipped defaults so the identity colors
|
||||
// survive (hasPalette() counts an app-colors-only file as a palette,
|
||||
// so those are kept wholesale and never reach here empty).
|
||||
for (auto it = themeDefault.appColors.cbegin(); it != themeDefault.appColors.cend(); ++it) {
|
||||
if (!palette.appColors.contains(it.key())) {
|
||||
palette.appColors.insert(it.key(), it.value());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
palette = themeDefault;
|
||||
}
|
||||
|
||||
applyStyleAndPalette(themeName, themeCfg, palette, activeScheme);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue