One named parameter tuning for one shader pack. More...
#include <PhosphorShaders/ShaderPreset.h>
Public Member Functions | |
| bool | isValid () const |
| QJsonObject | toJson () const |
| Serialise a USER preset. | |
| bool | operator== (const ShaderPreset &other) const |
| bool | operator!= (const ShaderPreset &other) const |
Static Public Member Functions | |
| static bool | isUsableId (const QString &id) |
Whether id is safe to use as both an identity and a path component. | |
| static ShaderPreset | fromJson (const QJsonObject &obj, const QString &fallbackId=QString()) |
| Parse a user preset file body. | |
Public Attributes | |
| QString | id |
| Stable id, MEANT to be unique within (family, packId) — the settings app mints a UUID for each user preset so a rename never breaks an assignment pointing at it, and a pack-declared preset uses its key in the metadata presets block. | |
| QString | name |
| Display name. | |
| QString | packId |
| The pack this preset tunes. | |
| QVariantMap | params |
| The tuning itself: { paramId -> value }. | |
| bool | readOnly = false |
| True for a pack-declared preset. | |
| QString | sourcePath |
| Absolute path of the file backing a user preset. | |
Static Public Attributes | |
| static constexpr qsizetype | MaxNameChars = 128 |
| Longest display name fromJson keeps, matching the cap the settings app's rename dialog applies to a typed name. | |
| static constexpr qsizetype | MaxIdChars = 256 |
| Longest id isUsableId accepts. | |
| static constexpr qsizetype | MaxParams = 64 |
| Most parameter entries fromJson keeps, and the cap the settings bridge applies when it WRITES a preset. | |
| static constexpr qsizetype | MaxValueChars = 1024 |
| Longest string VALUE kept in a preset's parameter map (an image path or a colour literal). | |
One named parameter tuning for one shader pack.
Two provenances share this type and one id namespace:
• Pack-declared — the presets block of a pack's metadata.json. Read-only: the pack author ships them and an update replaces them. The id is the preset's key in that block. • User — a JSON file under the user preset root. Editable, and the thing an assignment normally points at.
An assignment stores presetId plus only the parameters the user changed afterwards, so the effective parameter map is params overlaid with those deltas. That is what makes editing a preset move every assignment bound to it: the assignment holds a reference, never a copy.
|
static |
|
static |
Whether id is safe to use as both an identity and a path component.
Rejects empty, over-long, ., .., and anything containing a path separator or a NUL. The write side builds <dir>/<id>.json, so an id from a hand-editable file is a traversal vector; this is the check that closes it at the parse boundary.
|
inline |
|
inline |
| bool PhosphorShaders::ShaderPreset::operator== | ( | const ShaderPreset & | other | ) | const |
| QJsonObject PhosphorShaders::ShaderPreset::toJson | ( | ) | const |
Serialise a USER preset.
Pack-declared presets are written by their pack's metadata.json and never round-trip through here.
| QString PhosphorShaders::ShaderPreset::id |
Stable id, MEANT to be unique within (family, packId) — the settings app mints a UUID for each user preset so a rename never breaks an assignment pointing at it, and a pack-declared preset uses its key in the metadata presets block.
Nothing enforces it, though: a hand-written preset file may declare any id, or none, in which case the loader falls back to the filename stem. So an id is a UUID when the app created it and arbitrary text otherwise; isUsableId is what keeps the arbitrary case safe, and setUserPresets warns when two files claim one id.
|
staticconstexpr |
Longest id isUsableId accepts.
An id becomes a path component, so this also keeps a pathological one out of a filename.
|
staticconstexpr |
Longest display name fromJson keeps, matching the cap the settings app's rename dialog applies to a typed name.
Counted in UTF-16 units, the same unit QString::size() and that dialog use.
|
staticconstexpr |
Most parameter entries fromJson keeps, and the cap the settings bridge applies when it WRITES a preset.
One number for both halves: the bridge carried its own copy, so a hand-written file reached resolveParams with no cap at all while a preset the app saved was bounded. A pack declares at most 48 parameters (the parameters maxItems in every family's metadata schema), so this is deliberately above that: an entry naming no declared parameter is inert at resolve time, and refusing a preset over it would discard the usable keys beside it.
|
staticconstexpr |
Longest string VALUE kept in a preset's parameter map (an image path or a colour literal).
Shared with the settings bridge for the same reason MaxParams is.
| QString PhosphorShaders::ShaderPreset::name |
Display name.
Free-form, and NOT an identity — two presets may share one, and renaming changes nothing an assignment depends on.
| QString PhosphorShaders::ShaderPreset::packId |
The pack this preset tunes.
A preset is only offered for its own pack: parameter ids mean nothing across packs.
| QVariantMap PhosphorShaders::ShaderPreset::params |
The tuning itself: { paramId -> value }.
Names a subset of the pack's declared parameters; ids the pack does not declare are inert at resolve time.
| bool PhosphorShaders::ShaderPreset::readOnly = false |
True for a pack-declared preset.
Such a preset can be duplicated into a user preset but never edited or deleted in place — it belongs to the pack, and the next pack update would overwrite the edit anyway.
| QString PhosphorShaders::ShaderPreset::sourcePath |
Absolute path of the file backing a user preset.
Empty for a pack-declared one, which has no file of its own.