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

Load/save store for scrolling templates. More...

#include <phosphor-zones/include/PhosphorZones/ScrollingTemplateStore.h>

Inheritance diagram for PhosphorZones::ScrollingTemplateStore:
[legend]

Signals

void templatesChanged ()
 The loaded template set changed (load, save, remove, duplicate).
 

Public Member Functions

 ScrollingTemplateStore (QObject *parent=nullptr)
 
void loadTemplates ()
 Rescan every data location (system first, user last).
 
QList< ScrollingTemplatetemplates () const
 All templates, name-sorted (case-insensitive) for stable UI order.
 
ScrollingTemplate templateById (const QUuid &id) const
 The template with id, or an invalid template.
 
bool contains (const QUuid &id) const
 
int count () const
 
QUuid saveTemplate (ScrollingTemplate templ)
 Persist templ (create or update).
 
bool removeTemplate (const QUuid &id)
 Delete the USER files for id.
 
QUuid duplicateTemplate (const QUuid &id, const QString &newName=QString())
 Store a copy of id under a fresh UUID with newName (or a "name (Copy)" derivative when empty).
 

Static Public Member Functions

static QString templateSubdirectory ()
 The data-location subdirectory templates live in, relative to GenericDataLocation.
 
static QString userTemplateDirectory ()
 Absolute path of the USER template directory (GenericDataLocation + templateSubdirectory()).
 

Detailed Description

Load/save store for scrolling templates.

The persistence peer of LayoutRegistry's layout loading, for the ScrollingTemplate object: JSON files in "plasmazones/scrolling-templates" under every GenericDataLocation. System directories load first and the user directory last, so a user file sharing a bundled template's id SHADOWS it (edit-a-bundled-template writes a user copy; deleting that copy resurfaces the original). Templates get their own directory rather than sharing the layouts directory, so the layout loader's sidecar skip-list stays untouched.

Mutations write the USER directory only and re-announce via templatesChanged. The store is process-local: the daemon owns the authoritative instance behind the D-Bus CRUD verbs, and the settings/KCM processes instantiate their own read view exactly as they do for the local LayoutRegistry.

Constructor & Destructor Documentation

◆ ScrollingTemplateStore()

PhosphorZones::ScrollingTemplateStore::ScrollingTemplateStore ( QObject *  parent = nullptr)
explicit

Member Function Documentation

◆ contains()

bool PhosphorZones::ScrollingTemplateStore::contains ( const QUuid &  id) const
inline

◆ count()

int PhosphorZones::ScrollingTemplateStore::count ( ) const
inline

◆ duplicateTemplate()

QUuid PhosphorZones::ScrollingTemplateStore::duplicateTemplate ( const QUuid &  id,
const QString &  newName = QString() 
)

Store a copy of id under a fresh UUID with newName (or a "name (Copy)" derivative when empty).

Returns the new id, null on failure.

◆ loadTemplates()

void PhosphorZones::ScrollingTemplateStore::loadTemplates ( )

Rescan every data location (system first, user last).

Emits templatesChanged when the loaded set differs.

◆ removeTemplate()

bool PhosphorZones::ScrollingTemplateStore::removeTemplate ( const QUuid &  id)

Delete the USER files for id.

Both candidates are removed: the entry's own sourcePath when that path lies inside the user directory (a hand-placed user file need not be named after its id) and the id-derived path, since those can be two different files carrying the same id. A bundled (system) template shadowed by a user file resurfaces on the rescan this triggers; a template whose loaded entry came from a system location is refused (returns false) — the UI disables delete for those. Returns true when no user file for id remains afterwards, which includes the case where the files were already gone: the requested state holds either way. Returns false when a file survives (a remove that failed, which is logged) and when there was no user file to target at all, since nothing was deleted and the entry is still visible.

◆ saveTemplate()

QUuid PhosphorZones::ScrollingTemplateStore::saveTemplate ( ScrollingTemplate  templ)

Persist templ (create or update).

A null id is assigned a fresh UUID. Normalizes first; refuses (returns null id) when the template is invalid after normalization or the write fails. A save that would store a byte-identical entry writes nothing and emits nothing, and still returns the stored id. Writes to <id>.json in the user directory and retires every other user file declaring the same id, so a hand-placed duplicate cannot win the next rescan and revert the save. Returns the stored id.

◆ templateById()

ScrollingTemplate PhosphorZones::ScrollingTemplateStore::templateById ( const QUuid &  id) const

The template with id, or an invalid template.

◆ templates()

QList< ScrollingTemplate > PhosphorZones::ScrollingTemplateStore::templates ( ) const

All templates, name-sorted (case-insensitive) for stable UI order.

◆ templatesChanged

void PhosphorZones::ScrollingTemplateStore::templatesChanged ( )
signal

The loaded template set changed (load, save, remove, duplicate).

◆ templateSubdirectory()

static QString PhosphorZones::ScrollingTemplateStore::templateSubdirectory ( )
static

The data-location subdirectory templates live in, relative to GenericDataLocation.

The single authority for the spelling; UI code that opens the folder must use this rather than inlining the path.

◆ userTemplateDirectory()

static QString PhosphorZones::ScrollingTemplateStore::userTemplateDirectory ( )
static

Absolute path of the USER template directory (GenericDataLocation + templateSubdirectory()).

Static because it reads nothing off the store: UI code that has to open or create the folder can call it without an instance, and must, rather than re-joining the two parts itself.


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