The handful of settings that must outlive a reload, and where they go. More...
| Import Statement: | import Clayground.Lab |
Theme, language and UI scale are not lab state - they are facts about the person and the screen. Losing them on every reload is what made the scale knob feel broken before it existed: you set it, the loader restarted, and it was small again.
Backed by Clayground.Storage when that module is present and by plain memory when it is not, so a sandbox that never links the storage plugin still runs and still switches themes - it just forgets on exit. Nothing here is ever required for a lab to work.
Keys in use by the kernel:
| Key | Meaning |
|---|---|
ui.theme | "light" or "dark" (LabTheme::mode) |
ui.scale | the LabTheme::uiScale factor |
ui.lang | the LabLang::lang code |
A lab may store its own under any other key; prefix them with the lab's slug so two labs sharing the store cannot collide.
Nowhere in QML: the store is a QML LocalStorage database, so it lands in whatever directory the host gave its engine. The dojo points that at ~/.clayground - the person's real settings - and a headless host that should not write there points it somewhere throwaway by setting CLAY_STORAGE_DIR before it builds its engine. clayrender does that by default (--prefs isolated), which is why a scripted --eval 'LabTheme.mode="dark"' cannot leave the next dojo session dark, and why a render always starts from the defaults unless it was run with --prefs user.
See also LabTheme, LabLang, and ScaleSwitch.
persistent : bool |
True when a backing store was found; false means memory only.
storeName : string |
Database name. One store for all labs, so the settings are the person's rather than the lab's.
void forget(string key) |
Drops a stored value.
string get(string key, var fallback) |
The stored value, or fallback when there is none.
Always a string (or the fallback as given) - callers coerce, because the store is a text store and pretending otherwise hides the moment a number arrives back as "1.3".
void set(string key, var value) |
Stores value under key, silently doing nothing if it cannot.