Cockatrice 2026-06-01-Development-3.1.0-beta.3
A 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 }
47 return {};
48 }
49
50 static Type fromId(const QString &id)
51 {
52 for (const auto &e : all()) {
53 if (id == e.id) {
54 return e.type;
55 }
56 }
57 return Theme; // default
58 }
59
60 static QString toDisplay(Type type)
61 {
62 for (const auto &e : all()) {
63 if (e.type == type) {
64 return QObject::tr(e.trKey);
65 }
66 }
67 return {};
68 }
69};
70
71#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:60
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:50
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