QcUiPalette Namespace
The colours of every game screen in one place. More...
| Header: | #include <clientcore/settings/QcUiPalette.h> |
Classes
| struct | ControlPair |
| struct | Entry |
| struct | TextPair |
Types
| enum class | Preset { Classic, QtDark, QtNeon } |
| enum class | Role { Text, TextSecondary, TextMuted, Heading, Link, …, RoleCount } |
Variables
| const QcUiPalette::Preset | defaultPreset |
| const double | largeTextMinimum |
| const double | normalTextMinimum |
| const Preset[3] | presets |
Functions
| QColor | color(QcUiPalette::Role role) |
| QColor | composite(const QColor &over, const QColor &under) |
| double | contrast(const QColor &a, const QColor &b) |
| QList<QcUiPalette::ControlPair> | controlPairs() |
| QPalette | controlPalette() |
| std::span<const QcUiPalette::Entry> | entries() |
| QString | name(QcUiPalette::Role role) |
| QcUiPalette::Preset | preset() |
| std::optional<QcUiPalette::Preset> | presetFromName(QStringView name) |
| void | setPreset(QcUiPalette::Preset preset) |
| QList<QcUiPalette::TextPair> | textPairs() |
| QList<QColor> | worldBackgrounds() |
| double | worstContrast(const QcUiPalette::TextPair &pair) |
Detailed Description
QML reads them as Theme (QcUiTheme); screens use no colours of their own. The text pairs below say which text colour stands on which backgrounds, so one test checks the contrast of all screens over the brightest and darkest world (snow, desert, water, night) instead of each screen on its own.
Classes
class ControlPair
Text and background roles of controlPalette() that controls draw together. More...
class Entry
A colour role with its QML name and colour. More...
class TextPair
A text colour over its backgrounds: layers from the world upwards (the first one lies directly on the world). More...
Type Documentation
enum class QcUiPalette::Preset
Colour variants of the menus (decision E-852; QTCRAFT_THEME chooses one, not a setting yet): the classic one (blue gradient, Qt green), one like the Qt web site (near-black background, neutral greys, Qt green) and the same with the brighter "Qt Neon" accent.
Each variant changes only a few roles of the classic palette; the contrast pairs hold for every one (test_ui_palette).
| Constant | Value | Description |
|---|---|---|
QcUiPalette::Preset::Classic | 0 | blue gradient, Qt green |
QcUiPalette::Preset::QtDark | 1 | like the Qt web site: near-black background, neutral greys, Qt green |
QcUiPalette::Preset::QtNeon | 2 | QtDark with the brighter "Qt Neon" accent |
enum class QcUiPalette::Role
The colour roles; each is a property of Theme in QML.
| Constant | Value | Description |
|---|---|---|
QcUiPalette::Role::Text | 0 | Texts: the normal text. |
QcUiPalette::Role::TextSecondary | 1 | less important text |
QcUiPalette::Role::TextMuted | 2 | hints and disabled-looking text |
QcUiPalette::Role::Heading | 3 | headings |
QcUiPalette::Role::Link | 4 | links |
QcUiPalette::Role::Warning | 5 | warnings |
QcUiPalette::Role::Error | 6 | errors |
QcUiPalette::Role::TextOutline | 7 | Shadow and outline around texts and icons over the world. |
QcUiPalette::Role::HudBackdrop | 8 | Backgrounds, from the world upwards: behind HUD texts on the world. |
QcUiPalette::Role::Scrim | 9 | dims the world behind a screen |
QcUiPalette::Role::ScrimStrong | 10 | dims the world more |
QcUiPalette::Role::DeathScrim | 11 | the death screen over the world |
QcUiPalette::Role::Panel | 12 | the panels of the screens |
QcUiPalette::Role::PanelSolid | 13 | The panel without transparency: screens and dialogs over other screens (ScreenFrame). |
QcUiPalette::Role::PanelRaised | 14 | a part raised on a panel (groups, the chosen row) |
QcUiPalette::Role::PanelBorder | 15 | the edge of a panel |
QcUiPalette::Role::MenuTop | 16 | top of the main menu's gradient |
QcUiPalette::Role::MenuBottom | 17 | bottom of the main menu's gradient |
QcUiPalette::Role::Slot | 18 | Slots, bars and markers: a slot on a panel. |
QcUiPalette::Role::HudSlot | 19 | Hotbar slots lie directly on the world: darker than slots on a panel. |
QcUiPalette::Role::SlotHover | 20 | a slot under the pointer |
QcUiPalette::Role::SlotBorder | 21 | the edge of a slot |
QcUiPalette::Role::SwatchBorder | 22 | Edge of the colour swatches of the character screen: visible on the panel and around the darkest colours (black hair), 3:1 as WCAG asks of controls. |
QcUiPalette::Role::SlotPicked | 23 | a slot whose stack is picked up |
QcUiPalette::Role::IconBackdrop | 24 | Faint light behind item icons, so dark items (coal, obsidian) stand out on dark slots. |
QcUiPalette::Role::Selection | 25 | the edge of the selected slot |
QcUiPalette::Role::FocusRing | 26 | The ring around the item the pad's focus is on (decision E-583). |
QcUiPalette::Role::PadGlyph | 27 | Pad button symbols (decision E-612): the disc behind a symbol and the colours of the face buttons' letters and shapes (plain colours, no logos). |
QcUiPalette::Role::PadGreen | 28 | the green face button |
QcUiPalette::Role::PadRed | 29 | the red face button |
QcUiPalette::Role::PadBlue | 30 | the blue face button |
QcUiPalette::Role::PadYellow | 31 | the yellow face button |
QcUiPalette::Role::PadPink | 32 | the pink face button |
QcUiPalette::Role::Crosshair | 33 | the crosshair |
QcUiPalette::Role::Progress | 34 | progress bars |
QcUiPalette::Role::Health | 35 | the health bar |
QcUiPalette::Role::Experience | 36 | The experience bar and level in the HUD (decision E-398). |
QcUiPalette::Role::Air | 37 | The air bubbles in the HUD (decision E-955). |
QcUiPalette::Role::Flame | 38 | the flame of a burning furnace |
QcUiPalette::Role::FlameCore | 39 | the core of that flame |
QcUiPalette::Role::DurabilityGood | 40 | durability bar of a tool in good shape |
QcUiPalette::Role::DurabilityLow | 41 | durability bar of a worn tool |
QcUiPalette::Role::DurabilityBad | 42 | durability bar of a tool about to break |
QcUiPalette::Role::StatusGood | 43 | States shown as a graphic, e.g. the signal bars of the player list (decision E-886): good, warning, bad. Tools keep their own durability colours. |
QcUiPalette::Role::StatusWarn | 44 | warning |
QcUiPalette::Role::StatusBad | 45 | bad |
QcUiPalette::Role::InfoButton | 46 | the info button of a slot |
QcUiPalette::Role::InfoButtonHover | 47 | the info button under the pointer |
QcUiPalette::Role::Separator | 48 | Handbook: separators, the selected row, link chips. |
QcUiPalette::Role::RowHighlight | 49 | the selected row |
QcUiPalette::Role::LinkBackground | 50 | link chips |
QcUiPalette::Role::LinkHover | 51 | a link chip under the pointer |
QcUiPalette::Role::TooltipBackground | 52 | Tooltips: nearly opaque, so the text reads the same over panels, headings and the world. |
QcUiPalette::Role::GraphFrame | 53 | Debug display: the frame and tick graphs and their budget line (16.7 ms, 50 ms). |
QcUiPalette::Role::GraphTick | 54 | the tick graph |
QcUiPalette::Role::GraphLimit | 55 | the budget line |
QcUiPalette::Role::DialFace | 56 | Dials of a held compass or clock (decision E-769): the compass face and rim, the clock's night and day halves, rim and hand. |
QcUiPalette::Role::DialRim | 57 | compass rim |
QcUiPalette::Role::ClockNight | 58 | night half of the clock |
QcUiPalette::Role::ClockDay | 59 | day half of the clock |
QcUiPalette::Role::ClockRim | 60 | clock rim |
QcUiPalette::Role::ClockHand | 61 | clock hand |
QcUiPalette::Role::SignBoard | 62 | The wooden board of the sign editor (decision E-766). |
QcUiPalette::Role::SignBorder | 63 | the edge of the board |
QcUiPalette::Role::MapPaper | 64 | A filled map in the hand (decision E-805): the paper with its edge and the players on it, the own one and the others, and the item frames showing the map (decision E-808). |
QcUiPalette::Role::MapPaperEdge | 65 | the edge of the paper |
QcUiPalette::Role::MapMarker | 66 | the own player |
QcUiPalette::Role::MapMarkerOther | 67 | the other players |
QcUiPalette::Role::MapMarkerFrame | 68 | item frames showing the map |
QcUiPalette::Role::Accent | 69 | Controls of the menus (decision E-845): the accent (Qt green) of the primary button, the filled part of sliders and switches and the chosen category, with the dark text that stands on it (white on Qt green reaches only 2.1:1); the secondary button in its states, the destructive button, the sunken field of text fields and lists, the empty track of sliders and switches (3:1 to the panel, WCAG 1.4.11), the knob of sliders and switches and the bevel that gives buttons their blocky edge (light above and left, dark below and right). |
QcUiPalette::Role::AccentHover | 70 | the accent under the pointer |
QcUiPalette::Role::AccentPressed | 71 | the accent pressed |
QcUiPalette::Role::AccentText | 72 | text on the accent |
QcUiPalette::Role::Button | 73 | the secondary button |
QcUiPalette::Role::ButtonHover | 74 | the secondary button under the pointer |
QcUiPalette::Role::ButtonPressed | 75 | the secondary button pressed |
QcUiPalette::Role::Danger | 76 | the destructive button |
QcUiPalette::Role::DangerHover | 77 | the destructive button under the pointer |
QcUiPalette::Role::ButtonDisabled | 78 | A button that cannot be used now, of any kind: a flat grey surface with grey text, so a disabled primary button does not look like the accent (decision E-852). |
QcUiPalette::Role::TextDisabled | 79 | text of a button that cannot be used |
QcUiPalette::Role::Field | 80 | the sunken field of text fields and lists |
QcUiPalette::Role::Track | 81 | the empty track of sliders and switches |
QcUiPalette::Role::Knob | 82 | the knob of sliders and switches |
QcUiPalette::Role::KnobOutline | 83 | The dark edge around a knob: it marks the knob on the accent fill (3:1) where the knob's own light colour does not. |
QcUiPalette::Role::BevelLight | 84 | light bevel above and left |
QcUiPalette::Role::BevelDark | 85 | dark bevel below and right |
QcUiPalette::Role::Parchment | 86 | The workbench screens (enchanting table and anvil, decision E-884): the parchment of the offers and the name field with its hovered and unusable states, the ink written on it (runes and letters) and the green of experience levels and costs. On parchment the levels take a dark green (a usable offer's light parchment) and a light red (an unusable offer's dark parchment). |
QcUiPalette::Role::ParchmentHover | 87 | parchment under the pointer |
QcUiPalette::Role::ParchmentDisabled | 88 | parchment of an unusable offer |
QcUiPalette::Role::Ink | 89 | runes and letters on parchment |
QcUiPalette::Role::InkDisabled | 90 | ink on unusable parchment |
QcUiPalette::Role::Level | 91 | experience levels and costs |
QcUiPalette::Role::LevelOnParchment | 92 | levels on usable parchment |
QcUiPalette::Role::ErrorOnParchment | 93 | levels on unusable parchment |
QcUiPalette::Role::Clear | 94 | Fully transparent (no background, no border). |
QcUiPalette::Role::RoleCount | 95 | the number of roles, not a colour |
Variable Documentation
const QcUiPalette::Preset QcUiPalette::defaultPreset
The variant the game starts with (Mensch 2026-10-22: Qt Neon on near-black).
const double QcUiPalette::largeTextMinimum
Contrast large text needs (WCAG AA).
const double QcUiPalette::normalTextMinimum
Contrast normal text needs (WCAG AA).
const Preset[3] QcUiPalette::presets
Every variant, in the order of their names A, B, C.
Function Documentation
QColor QcUiPalette::color(QcUiPalette::Role role)
Returns the colour of role in the chosen variant.
QColor QcUiPalette::composite(const QColor &over, const QColor &under)
Returns over (with alpha) drawn on an opaque under.
double QcUiPalette::contrast(const QColor &a, const QColor &b)
Returns the WCAG 2 contrast ratio of two opaque colours a and b (1 to 21).
QList<QcUiPalette::ControlPair> QcUiPalette::controlPairs()
Returns the text and background pairs of controlPalette() that the contrast test checks.
QPalette QcUiPalette::controlPalette()
Returns the palette of the Qt Quick Controls (decision E-279), set for the whole application: popups, dialogs, fields, combo boxes and their lists, labels and the attached tooltip take their colours from it instead of the system palette. The macOS system palette in the dark scheme pairs a translucent light tooltip background with black tooltip text and has light "alternate base" and "dark" colours, which are unreadable under white text.
std::span<const QcUiPalette::Entry> QcUiPalette::entries()
Returns the roles with the colours of the chosen variant.
QString QcUiPalette::name(QcUiPalette::Role role)
Returns the QML name of role (Theme.<name>).
QcUiPalette::Preset QcUiPalette::preset()
Returns the variant chosen for the process.
See also setPreset().
std::optional<QcUiPalette::Preset> QcUiPalette::presetFromName(QStringView name)
Returns the variant named name: "A"/"classic", "B"/"qt", "C"/"neon" (case does not matter); nothing for anything else.
void QcUiPalette::setPreset(QcUiPalette::Preset preset)
Chooses the variant preset for the whole process; before the QML engine reads Theme (QTCRAFT_THEME).
See also preset().
QList<QcUiPalette::TextPair> QcUiPalette::textPairs()
Returns the text pairs of every screen.
QList<QColor> QcUiPalette::worldBackgrounds()
Returns the worlds the screens appear over: snow, desert sand, sky, water, grass, night, cave.
double QcUiPalette::worstContrast(const QcUiPalette::TextPair &pair)
Returns the lowest contrast of pair over all world backgrounds.