Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
background_sources.h
Go to the documentation of this file.
1
6
7#ifndef COCKATRICE_BACKGROUND_SOURCES_H
8#define COCKATRICE_BACKGROUND_SOURCES_H
9
10#include <QList>
11#include <QObject>
12#include <QString>
13
15{
16 Q_GADGET
17public:
24 Q_ENUM(Type)
25
26 struct Entry
27 {
29 const char *id; // stable ID for settings
30 const char *trKey; // key for translation
31 };
32
33 static QList<Entry> all()
34 {
35 return {{Theme, "theme", QT_TR_NOOP("Theme")},
36 {RandomCardArt, "random_card_art", QT_TR_NOOP("Art crop of random card")},
37 {DeckFileArt, "deck_file_art", QT_TR_NOOP("Art crop of background.cod deck file")}};
38 }
39
40 static QString toId(Type type)
41 {
42 for (const auto &e : all()) {
43 if (e.type == type)
44 return e.id;
45 }
46 return {};
47 }
48
49 static Type fromId(const QString &id)
50 {
51 for (const auto &e : all()) {
52 if (id == e.id)
53 return e.type;
54 }
55 return Theme; // default
56 }
57
58 static QString toDisplay(Type type)
59 {
60 for (const auto &e : all()) {
61 if (e.type == type)
62 return QObject::tr(e.trKey);
63 }
64 return {};
65 }
66};
67
68#endif // COCKATRICE_BACKGROUND_SOURCES_H
Definition background_sources.h:15
Type
Definition background_sources.h:19
@ Theme
Definition background_sources.h:20
@ DeckFileArt
Definition background_sources.h:22
@ RandomCardArt
Definition background_sources.h:21
static QString toDisplay(Type type)
Definition background_sources.h:58
static QList< Entry > all()
Definition background_sources.h:33
static QString toId(Type type)
Definition background_sources.h:40
static Type fromId(const QString &id)
Definition background_sources.h:49
Definition background_sources.h:27
const char * id
Definition background_sources.h:29
const char * trKey
Definition background_sources.h:30
Type type
Definition background_sources.h:28