mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Client] Add [AppColors] application palette roles
The home-tab buttons' gradient over the static theme background was hardcoded, and accent-derived fallbacks could not be themed or edited: QPalette's role set is closed, so any application-specific color has to live in Cockatrice's own palette layer. - Add an AppColor::Role enum (AccentStrong / AccentSoft) stored on PaletteConfig and round-tripped from palette-<scheme>.toml under a new [AppColors] section. - Cache the applied app colors in ThemeManager and expose appColor(Role) with a palette-accent-derived fallback; emit paletteChanged() from applyStyleAndPalette so previews, scheme switches and OS dark mode repaint palette-driven widgets. - Fill both app roles in PaletteGenerator::fromAccent and surface them as a dedicated section in the palette editor. - Drive the home-tab buttons from appColor() whenever the background source is the theme (any theme, not just built-ins). - Ship AccentStrong / AccentSoft values in the Fusion and Default default palettes so the static home-tab buttons keep their classic greens. # Conflicts: # cockatrice/src/interface/widgets/general/home_widget.cpp
This commit is contained in:
parent
5d025ca0bd
commit
03684bf41d
11 changed files with 195 additions and 12 deletions
|
|
@ -133,6 +133,24 @@ QString PaletteConfig::toToml() const
|
|||
out += "\n";
|
||||
}
|
||||
|
||||
if (!appColors.isEmpty()) {
|
||||
QMetaEnum appEnum = QMetaEnum::fromType<AppColor::Role>();
|
||||
|
||||
out += "[AppColors]\n";
|
||||
|
||||
for (auto it = appColors.cbegin(); it != appColors.cend(); ++it) {
|
||||
const char *roleName = appEnum.valueToKey(it.key());
|
||||
|
||||
if (!roleName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
out += QString("%1 = %2\n").arg(QString(roleName), -20).arg(it.value().name(QColor::HexArgb));
|
||||
}
|
||||
|
||||
out += "\n";
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
@ -152,6 +170,7 @@ PaletteConfig PaletteConfig::fromFile(const QString &filePath)
|
|||
}
|
||||
|
||||
QMetaEnum roleEnum = QMetaEnum::fromType<QPalette::ColorRole>();
|
||||
QMetaEnum appEnum = QMetaEnum::fromType<AppColor::Role>();
|
||||
|
||||
QString currentSection;
|
||||
QPalette::ColorGroup currentGroup = QPalette::Active;
|
||||
|
|
@ -202,6 +221,26 @@ PaletteConfig PaletteConfig::fromFile(const QString &filePath)
|
|||
}
|
||||
}
|
||||
|
||||
QColor color(value);
|
||||
|
||||
if (!color.isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentSection.compare("AppColors", Qt::CaseInsensitive) == 0) {
|
||||
if (key.startsWith("AppColor::")) {
|
||||
key = key.mid(10);
|
||||
}
|
||||
|
||||
int appRoleInt = appEnum.keyToValue(key.toUtf8().constData());
|
||||
|
||||
if (appRoleInt >= 0) {
|
||||
cfg.appColors[static_cast<AppColor::Role>(appRoleInt)] = color;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!currentSection.startsWith("Palette", Qt::CaseInsensitive)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -216,11 +255,7 @@ PaletteConfig PaletteConfig::fromFile(const QString &filePath)
|
|||
continue;
|
||||
}
|
||||
|
||||
QColor color(value);
|
||||
|
||||
if (color.isValid()) {
|
||||
cfg.colors[currentGroup][static_cast<QPalette::ColorRole>(roleInt)] = color;
|
||||
}
|
||||
cfg.colors[currentGroup][static_cast<QPalette::ColorRole>(roleInt)] = color;
|
||||
}
|
||||
|
||||
return cfg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue