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
14
class
BackgroundSources
15
{
16
Q_GADGET
17
public
:
18
enum
Type
19
{
20
Theme
,
21
RandomCardArt
,
22
DeckFileArt
23
};
24
Q_ENUM(
Type
)
25
26
struct
Entry
27
{
28
Type
type
;
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
BackgroundSources
Definition
background_sources.h:15
BackgroundSources::Type
Type
Definition
background_sources.h:19
BackgroundSources::Theme
@ Theme
Definition
background_sources.h:20
BackgroundSources::DeckFileArt
@ DeckFileArt
Definition
background_sources.h:22
BackgroundSources::RandomCardArt
@ RandomCardArt
Definition
background_sources.h:21
BackgroundSources::toDisplay
static QString toDisplay(Type type)
Definition
background_sources.h:58
BackgroundSources::all
static QList< Entry > all()
Definition
background_sources.h:33
BackgroundSources::toId
static QString toId(Type type)
Definition
background_sources.h:40
BackgroundSources::fromId
static Type fromId(const QString &id)
Definition
background_sources.h:49
BackgroundSources::Entry
Definition
background_sources.h:27
BackgroundSources::Entry::id
const char * id
Definition
background_sources.h:29
BackgroundSources::Entry::trKey
const char * trKey
Definition
background_sources.h:30
BackgroundSources::Entry::type
Type type
Definition
background_sources.h:28
cockatrice
src
interface
widgets
general
background_sources.h
Generated by
1.14.0