mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 20:13:56 -07:00
Use enum for ThemeManager brushes (#5730)
* Use enum for ThemeManager brushes This patch introduces an enum to distinguish the different brushes that can be set by the theme (hand, stack, etc.) and generic functions taking the enum rather than having one copy of each function for each brush. This is preliminary work before merging StackZone and HandZone to simplify #4974. * Include <array> header * Header spacing
This commit is contained in:
parent
4ada011632
commit
2739550087
7 changed files with 58 additions and 99 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
#include <array>
|
||||
|
||||
inline Q_LOGGING_CATEGORY(ThemeManagerLog, "theme_manager");
|
||||
|
||||
|
|
@ -22,13 +23,23 @@ class ThemeManager : public QObject
|
|||
public:
|
||||
ThemeManager(QObject *parent = nullptr);
|
||||
|
||||
enum Role
|
||||
{
|
||||
MinRole = 0,
|
||||
Hand = MinRole,
|
||||
Stack,
|
||||
Table,
|
||||
Player,
|
||||
MaxRole = Player,
|
||||
};
|
||||
|
||||
private:
|
||||
QBrush handBgBrush, stackBgBrush, tableBgBrush, playerBgBrush;
|
||||
std::array<QBrush, Role::MaxRole + 1> brushes;
|
||||
QStringMap availableThemes;
|
||||
/*
|
||||
Internal cache for multiple backgrounds
|
||||
*/
|
||||
QBrushMap tableBgBrushesCache, stackBgBrushesCache, playerBgBrushesCache, handBgBrushesCache;
|
||||
std::array<QBrushMap, Role::MaxRole + 1> brushesCache;
|
||||
|
||||
protected:
|
||||
void ensureThemeDirectoryExists();
|
||||
|
|
@ -36,27 +47,10 @@ protected:
|
|||
QBrush loadExtraBrush(QString fileName, QBrush &fallbackBrush);
|
||||
|
||||
public:
|
||||
QBrush &getHandBgBrush()
|
||||
{
|
||||
return handBgBrush;
|
||||
}
|
||||
QBrush &getStackBgBrush()
|
||||
{
|
||||
return stackBgBrush;
|
||||
}
|
||||
QBrush &getTableBgBrush()
|
||||
{
|
||||
return tableBgBrush;
|
||||
}
|
||||
QBrush &getPlayerBgBrush()
|
||||
{
|
||||
return playerBgBrush;
|
||||
}
|
||||
QStringMap &getAvailableThemes();
|
||||
QBrush getExtraTableBgBrush(QString extraNumber, QBrush &fallbackBrush);
|
||||
QBrush getExtraStackBgBrush(QString extraNumber, QBrush &fallbackBrush);
|
||||
QBrush getExtraPlayerBgBrush(QString extraNumber, QBrush &fallbackBrush);
|
||||
QBrush getExtraHandBgBrush(QString extraNumber, QBrush &fallbackBrush);
|
||||
|
||||
QBrush &getBgBrush(Role zone);
|
||||
QBrush getExtraBgBrush(Role zone, int zoneId = 0);
|
||||
protected slots:
|
||||
void themeChangedSlot();
|
||||
signals:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue