mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
- 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.
62 lines
No EOL
1.6 KiB
C++
62 lines
No EOL
1.6 KiB
C++
#ifndef COCKATRICE_THEME_CONFIG_H
|
|
#define COCKATRICE_THEME_CONFIG_H
|
|
|
|
#include <QColor>
|
|
#include <QMap>
|
|
#include <QObject>
|
|
#include <QPalette>
|
|
#include <QString>
|
|
|
|
// Application-specific color roles, layered on top of the fixed QPalette role
|
|
// set. Stored in the same palette-<scheme>.toml under an [AppColors] section
|
|
// and editable from the palette editor, so theme authors can control colors
|
|
// beyond what Qt's palette can express.
|
|
namespace AppColor
|
|
{
|
|
Q_NAMESPACE
|
|
enum Role
|
|
{
|
|
AccentStrong,
|
|
AccentSoft,
|
|
};
|
|
Q_ENUM_NS(Role)
|
|
} // namespace AppColor
|
|
|
|
struct ThemeConfig
|
|
{
|
|
QString colorScheme;
|
|
QString styleName;
|
|
|
|
bool isEmpty() const;
|
|
QString toIni() const;
|
|
|
|
static ThemeConfig fromThemeDir(const QString &themeDirPath);
|
|
bool save(const QString &themeDirPath) const;
|
|
};
|
|
|
|
struct PaletteConfig
|
|
{
|
|
QMap<QPalette::ColorGroup, QMap<QPalette::ColorRole, QColor>> colors;
|
|
QMap<AppColor::Role, QColor> appColors;
|
|
|
|
bool operator==(const PaletteConfig &rhs) const
|
|
{
|
|
return colors == rhs.colors && appColors == rhs.appColors;
|
|
}
|
|
bool operator!=(const PaletteConfig &rhs) const
|
|
{
|
|
return !(*this == rhs);
|
|
}
|
|
bool hasPalette() const;
|
|
QString toToml() const;
|
|
|
|
static QString fileName(const QString &colorScheme);
|
|
|
|
static PaletteConfig fromFile(const QString &filePath);
|
|
static PaletteConfig fromScheme(const QString &themeDirPath, const QString &colorScheme);
|
|
static PaletteConfig fromDefault(const QString &themeDirPath, const QString &colorScheme);
|
|
|
|
QPalette apply(QPalette base) const;
|
|
};
|
|
|
|
#endif // COCKATRICE_THEME_CONFIG_H
|