Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorZones::LayoutSettingsStore Class Reference

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.
 

Detailed Description

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.

Member Function Documentation

◆ extractSettings()

static QJsonObject PhosphorZones::LayoutSettingsStore::extractSettings ( const QJsonObject &  fullLayout)
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.

◆ isEmpty()

bool PhosphorZones::LayoutSettingsStore::isEmpty ( ) const
inline

◆ loadFromFile()

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.

◆ mergeSettings()

static QJsonObject PhosphorZones::LayoutSettingsStore::mergeSettings ( QJsonObject  structural,
const QJsonObject &  settings 
)
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.

◆ removeLayout()

void PhosphorZones::LayoutSettingsStore::removeLayout ( const QString &  layoutId)

Drop a layout's settings entry (e.g. when the layout is deleted).

◆ saveToFile()

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.

◆ setSettingsFor()

void PhosphorZones::LayoutSettingsStore::setSettingsFor ( const QString &  layoutId,
const QJsonObject &  settings 
)

Store (or, when settings is empty, clear) the settings for a layout.

◆ settingsFor()

QJsonObject PhosphorZones::LayoutSettingsStore::settingsFor ( const QString &  layoutId) const

Settings for a layout (empty object if none stored).

◆ stripSettings()

static QJsonObject PhosphorZones::LayoutSettingsStore::stripSettings ( const QJsonObject &  fullLayout)
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.

Member Data Documentation

◆ SchemaVersion

constexpr int PhosphorZones::LayoutSettingsStore::SchemaVersion = 1
staticconstexpr

On-disk schema version for layout-settings.json.

Independent of the application config schema version.


The documentation for this class was generated from the following file: