morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
theme.hpp File Reference

applyTheme: the ui-theme/1 token values set on an engine's MorphUi Theme singleton, which every built-in component and every host component in that engine reads. More...

#include <functional>
#include <map>
#include <string>
#include <vector>
#include "../ui/theme.hpp"

Go to the source code of this file.

Functions

std::vector< std::string > morph::qt_quick::applyTheme (QQmlEngine &engine, ui::ThemeValues const &values, std::map< std::string, ui::ThemeValues, std::less<> > const &surfaces={})
 Sets a theme's values on engine's Theme singleton.
std::vector< std::string > morph::qt_quick::applyBundleTheme (QQmlEngine &engine, std::map< std::string, std::string, std::less<> > const &themes, std::map< std::string, std::string, std::less<> > const &icons={})
 Applies a bundle's theme to engine's Theme: the theme index's base, each of its surfaces resolved with that surface's layer, and its icon set. A bundle with no theme index applies the defaults and no icon set, so a client that opens a second application does not keep the first one's look.

Detailed Description

applyTheme: the ui-theme/1 token values set on an engine's MorphUi Theme singleton, which every built-in component and every host component in that engine reads.

Specified in docs/spec/qt_quick/backend.md, "Layout and theme".

Definition in file theme.hpp.

Function Documentation

◆ applyTheme()

std::vector< std::string > morph::qt_quick::applyTheme ( QQmlEngine & engine,
ui::ThemeValues const & values,
std::map< std::string, ui::ThemeValues, std::less<> > const & surfaces = {} )

Sets a theme's values on engine's Theme singleton.

Every MorphUi component binds its colours to Theme, and a host component that imports MorphUi reads the same instance, so both update. A path of the set the theme lacks has its default in values (ui::themeValues), which is the Theme property's own default, so applying ui::themeValues() restores the defaults. Call it on the engine's thread, before or after screens mount. A surface named in surfaces gets every colour role from its values: the theme resolved with that surface's layer (ui::resolveTheme), so a role the surface does not set is the theme's. A built-in surface (page, card, sidebar, toolbar) the map does not name keeps its built-in colours.

Parameters
engineThe engine the backend compiles its components in.
valuesThe values, from ui::themeValues.
surfacesThe theme's surfaces by name, each resolved with its layer; empty keeps the built-in ones.
Returns
The Theme properties that could not be set, a surface's as <name>.<role>; empty when every one was.

◆ applyBundleTheme()

std::vector< std::string > morph::qt_quick::applyBundleTheme ( QQmlEngine & engine,
std::map< std::string, std::string, std::less<> > const & themes,
std::map< std::string, std::string, std::less<> > const & icons = {} )

Applies a bundle's theme to engine's Theme: the theme index's base, each of its surfaces resolved with that surface's layer, and its icon set. A bundle with no theme index applies the defaults and no icon set, so a client that opens a second application does not keep the first one's look.

Parameters
engineThe engine the backend compiles its components in.
themesThe bundle's theme files by id (ui::Bundle::themes).
iconsThe bundle's icon set, by icon name, as SVG text (ui::Bundle::icons); empty declares none.
Returns
Why the theme could not be applied, or the Theme properties that could not be set; empty when it was applied whole.