Cockatrice/cockatrice/src/interface/palette_editor/palette_grid_widget.h
BruebachL cf0b453e75
[PaletteEditor] Ensure directory is writeable, don't fall back to alternate palette (#7048)
* [PaletteEditor] Ensure directory is writeable, don't fall back to alternate palette.

Took 17 minutes

* [ThemeManager] Extract system theme dir path resolution to helper, use it in default palette fetching

Took 8 minutes

* [ThemeManager] Expose styling again

Took 3 minutes

* [ThemeManager] Capture app palette before theme is applied for reverting

* [ThemeManager] Simply delete custom palette instead of reverting to default

* [ThemeManager] Generate and apply immediately on change.

* [PaletteEditor] Block grid signals during initial loading.

Took 5 minutes

* Address comments

Took 8 minutes

* Seed accent from scheme on reset and revert

Took 2 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-07-27 11:23:41 +02:00

41 lines
No EOL
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;
QScrollArea *scroll;
QWidget *gridHost;
QVBoxLayout *layout;
QVector<QLabel *> headerLabels;
QVector<QWidget *> rowShadeWidgets;
};
#endif // COCKATRICE_PALETTE_GRID_WIDGET_H