QtCraft API C++ classes QML types Handbook

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).

ConstantValueDescription
QcUiPalette::Preset::Classic0blue gradient, Qt green
QcUiPalette::Preset::QtDark1like the Qt web site: near-black background, neutral greys, Qt green
QcUiPalette::Preset::QtNeon2QtDark with the brighter "Qt Neon" accent

enum class QcUiPalette::Role

The colour roles; each is a property of Theme in QML.

ConstantValueDescription
QcUiPalette::Role::Text0Texts: the normal text.
QcUiPalette::Role::TextSecondary1less important text
QcUiPalette::Role::TextMuted2hints and disabled-looking text
QcUiPalette::Role::Heading3headings
QcUiPalette::Role::Link4links
QcUiPalette::Role::Warning5warnings
QcUiPalette::Role::Error6errors
QcUiPalette::Role::TextOutline7Shadow and outline around texts and icons over the world.
QcUiPalette::Role::HudBackdrop8Backgrounds, from the world upwards: behind HUD texts on the world.
QcUiPalette::Role::Scrim9dims the world behind a screen
QcUiPalette::Role::ScrimStrong10dims the world more
QcUiPalette::Role::DeathScrim11the death screen over the world
QcUiPalette::Role::Panel12the panels of the screens
QcUiPalette::Role::PanelSolid13The panel without transparency: screens and dialogs over other screens (ScreenFrame).
QcUiPalette::Role::PanelRaised14a part raised on a panel (groups, the chosen row)
QcUiPalette::Role::PanelBorder15the edge of a panel
QcUiPalette::Role::MenuTop16top of the main menu's gradient
QcUiPalette::Role::MenuBottom17bottom of the main menu's gradient
QcUiPalette::Role::Slot18Slots, bars and markers: a slot on a panel.
QcUiPalette::Role::HudSlot19Hotbar slots lie directly on the world: darker than slots on a panel.
QcUiPalette::Role::SlotHover20a slot under the pointer
QcUiPalette::Role::SlotBorder21the edge of a slot
QcUiPalette::Role::SwatchBorder22Edge 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::SlotPicked23a slot whose stack is picked up
QcUiPalette::Role::IconBackdrop24Faint light behind item icons, so dark items (coal, obsidian) stand out on dark slots.
QcUiPalette::Role::Selection25the edge of the selected slot
QcUiPalette::Role::FocusRing26The ring around the item the pad's focus is on (decision E-583).
QcUiPalette::Role::PadGlyph27Pad 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::PadGreen28the green face button
QcUiPalette::Role::PadRed29the red face button
QcUiPalette::Role::PadBlue30the blue face button
QcUiPalette::Role::PadYellow31the yellow face button
QcUiPalette::Role::PadPink32the pink face button
QcUiPalette::Role::Crosshair33the crosshair
QcUiPalette::Role::Progress34progress bars
QcUiPalette::Role::Health35the health bar
QcUiPalette::Role::Experience36The experience bar and level in the HUD (decision E-398).
QcUiPalette::Role::Air37The air bubbles in the HUD (decision E-955).
QcUiPalette::Role::Flame38the flame of a burning furnace
QcUiPalette::Role::FlameCore39the core of that flame
QcUiPalette::Role::DurabilityGood40durability bar of a tool in good shape
QcUiPalette::Role::DurabilityLow41durability bar of a worn tool
QcUiPalette::Role::DurabilityBad42durability bar of a tool about to break
QcUiPalette::Role::StatusGood43States 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::StatusWarn44warning
QcUiPalette::Role::StatusBad45bad
QcUiPalette::Role::InfoButton46the info button of a slot
QcUiPalette::Role::InfoButtonHover47the info button under the pointer
QcUiPalette::Role::Separator48Handbook: separators, the selected row, link chips.
QcUiPalette::Role::RowHighlight49the selected row
QcUiPalette::Role::LinkBackground50link chips
QcUiPalette::Role::LinkHover51a link chip under the pointer
QcUiPalette::Role::TooltipBackground52Tooltips: nearly opaque, so the text reads the same over panels, headings and the world.
QcUiPalette::Role::GraphFrame53Debug display: the frame and tick graphs and their budget line (16.7 ms, 50 ms).
QcUiPalette::Role::GraphTick54the tick graph
QcUiPalette::Role::GraphLimit55the budget line
QcUiPalette::Role::DialFace56Dials 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::DialRim57compass rim
QcUiPalette::Role::ClockNight58night half of the clock
QcUiPalette::Role::ClockDay59day half of the clock
QcUiPalette::Role::ClockRim60clock rim
QcUiPalette::Role::ClockHand61clock hand
QcUiPalette::Role::SignBoard62The wooden board of the sign editor (decision E-766).
QcUiPalette::Role::SignBorder63the edge of the board
QcUiPalette::Role::MapPaper64A 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::MapPaperEdge65the edge of the paper
QcUiPalette::Role::MapMarker66the own player
QcUiPalette::Role::MapMarkerOther67the other players
QcUiPalette::Role::MapMarkerFrame68item frames showing the map
QcUiPalette::Role::Accent69Controls 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::AccentHover70the accent under the pointer
QcUiPalette::Role::AccentPressed71the accent pressed
QcUiPalette::Role::AccentText72text on the accent
QcUiPalette::Role::Button73the secondary button
QcUiPalette::Role::ButtonHover74the secondary button under the pointer
QcUiPalette::Role::ButtonPressed75the secondary button pressed
QcUiPalette::Role::Danger76the destructive button
QcUiPalette::Role::DangerHover77the destructive button under the pointer
QcUiPalette::Role::ButtonDisabled78A 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::TextDisabled79text of a button that cannot be used
QcUiPalette::Role::Field80the sunken field of text fields and lists
QcUiPalette::Role::Track81the empty track of sliders and switches
QcUiPalette::Role::Knob82the knob of sliders and switches
QcUiPalette::Role::KnobOutline83The 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::BevelLight84light bevel above and left
QcUiPalette::Role::BevelDark85dark bevel below and right
QcUiPalette::Role::Parchment86The 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::ParchmentHover87parchment under the pointer
QcUiPalette::Role::ParchmentDisabled88parchment of an unusable offer
QcUiPalette::Role::Ink89runes and letters on parchment
QcUiPalette::Role::InkDisabled90ink on unusable parchment
QcUiPalette::Role::Level91experience levels and costs
QcUiPalette::Role::LevelOnParchment92levels on usable parchment
QcUiPalette::Role::ErrorOnParchment93levels on unusable parchment
QcUiPalette::Role::Clear94Fully transparent (no background, no border).
QcUiPalette::Role::RoleCount95the 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.