Cockatrice 2026-10-19-Development-3.1.2-beta.2
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 <QSharedPointer>
13#include <QString>
14#include <QtGlobal>
15#include <qtmetamacros.h>
16
18{
19 Q_GADGET
20public:
27 Q_ENUM(Type)
28
29 struct Entry
30 {
32 const char *id; // stable ID for settings
33 const char *trKey; // key for translation
34 };
35
37 {
38 return {{Theme, "theme", QT_TR_NOOP("Theme")},
39 {RandomCardArt, "random_card_art", QT_TR_NOOP("Art crop of random card")},
40 {DeckFileArt, "deck_file_art", QT_TR_NOOP("Art crop of background.cod deck file")}};
41 }
42
43 static QString toId(Type type)
44 {
45 for (const auto &e : all()) {
46 if (e.type == type) {
47 return e.id;
48 }
49 }
50 return {};
51 }
52
53 static Type fromId(const QString &id)
54 {
55 for (const auto &e : all()) {
56 if (id == e.id) {
57 return e.type;
58 }
59 }
60 return Theme; // default
61 }
62
63 static QString toDisplay(Type type)
64 {
65 for (const auto &e : all()) {
66 if (e.type == type) {
67 return QObject::tr(e.trKey);
68 }
69 }
70 return {};
71 }
72};
73
74#endif // COCKATRICE_BACKGROUND_SOURCES_H
Definition background_sources.h:18
Type
Definition background_sources.h:22
@ Theme
Definition background_sources.h:23
@ DeckFileArt
Definition background_sources.h:25
@ RandomCardArt
Definition background_sources.h:24
static QString toDisplay(Type type)
Definition background_sources.h:63
static QList< Entry > all()
Definition background_sources.h:36
static QString toId(Type type)
Definition background_sources.h:43
static Type fromId(const QString &id)
Definition background_sources.h:53
Definition remote_connection_controller.h:20
EmailType type
Definition smtpclient.cpp:30
Definition background_sources.h:30
const char * id
Definition background_sources.h:32
const char * trKey
Definition background_sources.h:33
Type type
Definition background_sources.h:31