Theme.h header
#include <ew/app/Theme.h>
Namespace ew::app
Theme struct
struct ew::app::Theme
An application colour theme: a named set of palette colours (as "#rrggbb" hex strings, so this stays free of any GUI type) that the desktop client turns into a QPalette. The nine colours are the essential palette roles; the client derives the rest (alternating rows, tooltips, disabled text) from them. dark lets the client adjust derived shades and any dark-mode-specific styling.
Members
QString ew::app::settings::Theme::name
The theme's display name (also its stable identifier, e.g. "Light", "Dark", "Sepia").
bool ew::app::settings::Theme::dark = false
Whether this is a dark theme (a dark window with light text).
QString ew::app::settings::Theme::window
Window/panel background.
QString ew::app::settings::Theme::windowText
Text on the window background.
QString ew::app::settings::Theme::base
Background of text-entry surfaces (editors, fields, lists).
QString ew::app::settings::Theme::text
Text on base surfaces.
QString ew::app::settings::Theme::button
Button background.
QString ew::app::settings::Theme::buttonText
Text on buttons.
QString ew::app::settings::Theme::highlight
Selection/accent background.
QString ew::app::settings::Theme::highlightedText
Text on the selection/accent background.
QString ew::app::settings::Theme::link
Hyperlink colour.
Functions
std::vector< Theme > ew::app::settings::availableThemes(const plugin::ContributionRegistry &contributions)
The built-in themes followed by every plugin-contributed theme (contributions), in that order. A contributed theme whose name collides with a built-in or an earlier contribution is skipped, so a plugin can never shadow "Light"/"Dark". This is what the theme picker should iterate.
std::vector< Theme > ew::app::settings::availableThemes(const plugin::ContributionRegistry &contributions, const std::vector< Theme > &customThemes)
The built-ins, then the user's own customThemes, then every plugin-contributed theme, each added only when its name is not already taken. The order is the precedence: a built-in can never be shadowed, and the user's own theme wins over a plugin's of the same name – the rule the prompt-command and macro libraries already follow, because a name the user chose should not silently mean someone else's colours.
std::vector< Theme > ew::app::settings::builtInThemes()
The built-in themes shipped with the app, in display order: Light, Dark, Sepia, High Contrast.
bool ew::app::settings::isUsableTheme(const Theme &theme)
Whether theme can be applied: it has a name and every one of its ten colours is a #rrggbb value. A theme read from a file or a stale setting can be missing fields (themeFromJson leaves those empty), and an empty colour string makes an unusable palette – black on black – so an imported or restored theme is checked before it is offered rather than after it is applied.
std::vector< Theme > ew::app::settings::loadCustomThemes(const Settings &settings)
The themes the user has made, as stored by saveCustomThemes. Returns none when nothing is saved, when the stored value is not a theme array, or for any entry that is not usable – a corrupt setting costs the user their custom themes, never a window they cannot read.
void ew::app::settings::saveCustomThemes(Settings &settings, const std::vector< Theme > &themes)
Replaces the user's saved themes with themes, removing the setting entirely when empty.
Theme ew::app::settings::themeByName(const QString &name)
The built-in theme with name (case-sensitive), or the Light theme when none matches – so a stored theme name that no longer exists falls back gracefully.
Theme ew::app::settings::themeByName(const QString &name, const plugin::ContributionRegistry &contributions)
themeByName resolved across availableThemes(contributions): a plugin theme that was selected and persisted still resolves on the next launch. Falls back to the Light theme when no name matches (as themeByName does).
Theme ew::app::settings::themeByName(const QString &name, const plugin::ContributionRegistry &contributions, const std::vector< Theme > &customThemes)
themeByName resolved across availableThemes(contributions, customThemes), so a theme the user made and selected still resolves on the next launch. Falls back to the Light theme.
Theme ew::app::settings::themeFromJson(const QByteArray &json)
Parses a theme from json. Missing colour fields become empty strings, so an imported theme must be checked with isUsableTheme before it is offered to the user.
QByteArray ew::app::settings::themeToJson(const Theme &theme)
Serialises theme to JSON bytes – the form a theme is exported and shared in.