Persists per-layout SETTINGS in a sidecar, keyed by layout UUID, separately from the structural layout files. More...
#include <phosphor-zones/include/PhosphorZones/LayoutSettingsStore.h>
Public Member Functions | |
| bool | loadFromFile (const QString &path) |
Replace the in-memory map with the contents of path. | |
| bool | saveToFile (const QString &path) const |
Atomically write the in-memory map to path (stamped with SchemaVersion). | |
| QJsonObject | settingsFor (const QString &layoutId) const |
| Settings for a layout (empty object if none stored). | |
| void | setSettingsFor (const QString &layoutId, const QJsonObject &settings) |
Store (or, when settings is empty, clear) the settings for a layout. | |
| void | removeLayout (const QString &layoutId) |
| Drop a layout's settings entry (e.g. when the layout is deleted). | |
| bool | isEmpty () const |
Static Public Member Functions | |
| static QJsonObject | extractSettings (const QJsonObject &fullLayout) |
| Pull the settings out of a full layout JSON. | |
| static QJsonObject | stripSettings (const QJsonObject &fullLayout) |
| Return the structural-only layout JSON: the full layout minus every settings key (and minus each zone's appearance block). | |
| static QJsonObject | mergeSettings (QJsonObject structural, const QJsonObject &settings) |
| Overlay a settings object (as produced by extractSettings) back onto a structural layout JSON, yielding a full layout JSON for Layout::fromJson. | |
Static Public Attributes | |
| static constexpr int | SchemaVersion = 1 |
| On-disk schema version for layout-settings.json. | |
Persists per-layout SETTINGS in a sidecar, keyed by layout UUID, separately from the structural layout files.
A layout file should describe the layout — its zones and geometry, identity, and matching rules. The user-preference SETTINGS that can be tuned per layout (per-zone appearance, gap/padding overrides, showZoneNumbers, overlay display mode, auto-assign, full-screen geometry mode, shader binding — the canonical set is layoutSettingKeys in the .cpp) are NOT part of that structural definition and no longer live inside the layout .json. They live here, in a single layout-settings.json sidecar keyed by layout UUID — the same sibling-store pattern used by windowrules.json / quicklayouts.json.
The split happens only at the file boundary. The in-memory Layout/Zone model still carries every setting (so the editor, D-Bus wire format, and runtime consumers are unchanged): stripSettings is applied to Layout::toJson on write, and mergeSettings re-applies the stored values before Layout::fromJson on read.
|
static |
Pull the settings out of a full layout JSON.
Returns a settings object (the per-layout setting keys plus a per-zone appearance map keyed by zone UUID). Returns an empty object when the layout carries no settings.
|
inline |
| bool PhosphorZones::LayoutSettingsStore::loadFromFile | ( | const QString & | path | ) |
Replace the in-memory map with the contents of path.
A missing file is treated as an empty store (returns true). Returns false only on a parse error.
|
static |
Overlay a settings object (as produced by extractSettings) back onto a structural layout JSON, yielding a full layout JSON for Layout::fromJson.
Keys already present in structural are preserved when settings does not override them — so a not-yet-split (full-format) layout file still round-trips correctly even with an empty store entry.
| void PhosphorZones::LayoutSettingsStore::removeLayout | ( | const QString & | layoutId | ) |
Drop a layout's settings entry (e.g. when the layout is deleted).
| bool PhosphorZones::LayoutSettingsStore::saveToFile | ( | const QString & | path | ) | const |
Atomically write the in-memory map to path (stamped with SchemaVersion).
Layouts with empty settings are omitted.
| void PhosphorZones::LayoutSettingsStore::setSettingsFor | ( | const QString & | layoutId, |
| const QJsonObject & | settings | ||
| ) |
Store (or, when settings is empty, clear) the settings for a layout.
| QJsonObject PhosphorZones::LayoutSettingsStore::settingsFor | ( | const QString & | layoutId | ) | const |
Settings for a layout (empty object if none stored).
|
static |
Return the structural-only layout JSON: the full layout minus every settings key (and minus each zone's appearance block).
This is what gets written to the layout .json.
|
staticconstexpr |
On-disk schema version for layout-settings.json.
Independent of the application config schema version.