Cockatrice/cockatrice/src/interface/palette_editor/palette_grid_widget.h
Lukas Brübach 7da67c2a3f
[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
2026-09-18 13:19:34 +02:00

42 lines
No EOL
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef COCKATRICE_PALETTE_GRID_WIDGET_H
#define COCKATRICE_PALETTE_GRID_WIDGET_H
#include "../theme_config.h"
#include "color_button.h"
#include <QMap>
#include <QPalette>
#include <QVBoxLayout>
#include <QWidget>
class QLabel;
class QScrollArea;
// Scrollable grid of ColorButtons — one per (ColorGroup × ColorRole) cell.
// Owns the load/read round-trip for PaletteConfig but has no file I/O itself.
class PaletteGridWidget : public QWidget
{
Q_OBJECT
public:
explicit PaletteGridWidget(QWidget *parent = nullptr);
void loadPalette(const PaletteConfig &cfg);
PaletteConfig currentPaletteConfig() const;
signals:
void paletteChanged();
private:
void buildGrid(QWidget *host);
void changeEvent(QEvent *e);
void refreshChromePalettes();
QMap<QPalette::ColorGroup, QMap<QPalette::ColorRole, ColorButton *>> colorButtons;
QMap<AppColor::Role, ColorButton *> appColorButtons;
QScrollArea *scroll;
QWidget *gridHost;
QVBoxLayout *layout;
QVector<QLabel *> headerLabels;
QVector<QWidget *> rowShadeWidgets;
};
#endif // COCKATRICE_PALETTE_GRID_WIDGET_H