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

Registry mapping profile path strings to Profile values. More...

#include <PhosphorAnimation/PhosphorProfileRegistry.h>

Inheritance diagram for PhosphorAnimation::PhosphorProfileRegistry:
[legend]

Signals

void profileChanged (const QString &path)
 Fired when a profile is registered, replaced, or unregistered.
void profilesReloaded ()
 Fired only on wholesale operations (reloadAll, clear).
void ownerReloaded (const QString &ownerTag)
 Fired at the end of a reloadFromOwner/clearOwner batch if any changes occurred.

Public Member Functions

 PhosphorProfileRegistry (QObject *parent=nullptr)
 ~PhosphorProfileRegistry () override
 PhosphorProfileRegistry (const PhosphorProfileRegistry &)=delete
PhosphorProfileRegistry & operator= (const PhosphorProfileRegistry &)=delete
std::optional< Profile > resolve (const QString &path) const
 Resolve path to a Profile if registered.
Profile resolveWithInheritance (const QString &path) const
 Resolve path with parent-chain inheritance.
void setLowPrecedenceOwnerTag (const QString &tag)
 Configure the owner tag whose entries should be treated as the lowest-precedence layer in resolveWithInheritance.
void registerProfile (const QString &path, const Profile &profile)
 Register or replace the profile at path (direct/untagged owner).
void registerProfile (const QString &path, const Profile &profile, const QString &ownerTag)
 Register or replace at path, stamped with an owner tag.
void unregisterProfile (const QString &path)
 Remove path from the NON-SEED layer.
void reloadFromOwner (const QString &ownerTag, const QHash< QString, Profile > &profiles)
 Replace the subset owned by ownerTag with profiles.
void clearOwner (const QString &ownerTag)
 Remove every entry owned by ownerTag.
void reloadAll (const QHash< QString, Profile > &profiles)
 Wholesale replace the entire registry. TEST-ONLY semantics.
void clear ()
 Clear the registry. Fires profilesReloaded().
QString ownerOf (const QString &path) const
 Current owner tag for path, or empty string.
QHash< QString, Profile > snapshot () const
 Thread-safe copy of every NON-SEED (path → Profile) pair, owner tags discarded.
QHash< QString, Profile > snapshotExcludingLowPrecedence () const
 The same content as snapshot(), named for the reason a publisher needs it.
int profileCount () const
 Current path count across BOTH layers, so a registry whose whole content is seeds does not report empty.
bool hasProfile (const QString &path) const
 Is path registered in EITHER layer? Thread-safe.

Static Public Member Functions

static void setDefaultRegistry (PhosphorProfileRegistry *registry)
 Publish registry as the process-wide default for QML resolution.
static PhosphorProfileRegistry * defaultRegistry ()
 Read the process-wide default; nullptr if none published yet.

Detailed Description

Registry mapping profile path strings to Profile values.

Consumers register profiles here; settings reloads call registerProfile() to publish updates. Thread-safe (internal mutex).

Constructor & Destructor Documentation

◆ PhosphorProfileRegistry() [1/2]

PhosphorAnimation::PhosphorProfileRegistry::PhosphorProfileRegistry ( QObject * parent = nullptr)
explicit

◆ ~PhosphorProfileRegistry()

PhosphorAnimation::PhosphorProfileRegistry::~PhosphorProfileRegistry ( )
override

◆ PhosphorProfileRegistry() [2/2]

PhosphorAnimation::PhosphorProfileRegistry::PhosphorProfileRegistry ( const PhosphorProfileRegistry & )
delete

Member Function Documentation

◆ clear()

void PhosphorAnimation::PhosphorProfileRegistry::clear ( )

Clear the registry. Fires profilesReloaded().

◆ clearOwner()

void PhosphorAnimation::PhosphorProfileRegistry::clearOwner ( const QString & ownerTag)

Remove every entry owned by ownerTag.

◆ defaultRegistry()

PhosphorProfileRegistry * PhosphorAnimation::PhosphorProfileRegistry::defaultRegistry ( )
static

Read the process-wide default; nullptr if none published yet.

◆ hasProfile()

bool PhosphorAnimation::PhosphorProfileRegistry::hasProfile ( const QString & path) const

Is path registered in EITHER layer? Thread-safe.

◆ operator=()

PhosphorProfileRegistry & PhosphorAnimation::PhosphorProfileRegistry::operator= ( const PhosphorProfileRegistry & )
delete

◆ ownerOf()

QString PhosphorAnimation::PhosphorProfileRegistry::ownerOf ( const QString & path) const

Current owner tag for path, or empty string.

◆ ownerReloaded

void PhosphorAnimation::PhosphorProfileRegistry::ownerReloaded ( const QString & ownerTag)
signal

Fired at the end of a reloadFromOwner/clearOwner batch if any changes occurred.

◆ profileChanged

void PhosphorAnimation::PhosphorProfileRegistry::profileChanged ( const QString & path)
signal

Fired when a profile is registered, replaced, or unregistered.

◆ profileCount()

int PhosphorAnimation::PhosphorProfileRegistry::profileCount ( ) const

Current path count across BOTH layers, so a registry whose whole content is seeds does not report empty.

Does not agree with snapshot().size(), which is non-seed only. Thread-safe.

◆ profilesReloaded

void PhosphorAnimation::PhosphorProfileRegistry::profilesReloaded ( )
signal

Fired only on wholesale operations (reloadAll, clear).

◆ registerProfile() [1/2]

void PhosphorAnimation::PhosphorProfileRegistry::registerProfile ( const QString & path,
const Profile & profile )

Register or replace the profile at path (direct/untagged owner).

◆ registerProfile() [2/2]

void PhosphorAnimation::PhosphorProfileRegistry::registerProfile ( const QString & path,
const Profile & profile,
const QString & ownerTag )

Register or replace at path, stamped with an owner tag.

◆ reloadAll()

void PhosphorAnimation::PhosphorProfileRegistry::reloadAll ( const QHash< QString, Profile > & profiles)

Wholesale replace the entire registry. TEST-ONLY semantics.

◆ reloadFromOwner()

void PhosphorAnimation::PhosphorProfileRegistry::reloadFromOwner ( const QString & ownerTag,
const QHash< QString, Profile > & profiles )

Replace the subset owned by ownerTag with profiles.

Entries owned by other tags are preserved.

◆ resolve()

std::optional< Profile > PhosphorAnimation::PhosphorProfileRegistry::resolve ( const QString & path) const

Resolve path to a Profile if registered.

Exact match only — returns nullopt if no entry exists at exactly path. For inheritance-aware resolution that walks the parent chain and overlays each level (the semantics every animation consumer actually wants — a parent-node override at popup SHOULD propagate to popup.layoutPicker.show), use resolveWithInheritance instead.

◆ resolveWithInheritance()

Profile PhosphorAnimation::PhosphorProfileRegistry::resolveWithInheritance ( const QString & path) const

Resolve path with parent-chain inheritance.

Walks path → parent(path) → ... → the path's root segment, starting from a default-constructed Profile, and overlays each registered entry along the chain — every engaged optional field in a deeper entry replaces the shallower one (deeper-leaf-wins), while unset fields inherit from the parent. Falls through to the library defaults via Profile::withDefaults() so the returned value is always fully populated.

Two-layer overlay. The walk runs in TWO passes: pass 1 overlays the seed store, pass 2 overlays everything else (Settings publishes, per-event config overrides). Pass 2 always wins over pass 1, regardless of depth — so a user edit at the parent path widget (duration=800 ms) still cascades to a leaf like widget.pulse.fast even when the leaf has a seed entry (500 ms cubic-bezier). Without the two-layer model, leaf seeds would silently shadow parent user-overrides via the deeper-wins rule — exactly the bug the bundled-JSON deletion fixed.

Which store an entry lives in is decided at WRITE time, against the tag configured by setLowPrecedenceOwnerTag, so both passes run whether or not a tag is set. With no tag configured the seed store is simply empty and pass 1 contributes nothing.

◆ setDefaultRegistry()

void PhosphorAnimation::PhosphorProfileRegistry::setDefaultRegistry ( PhosphorProfileRegistry * registry)
static

Publish registry as the process-wide default for QML resolution.

◆ setLowPrecedenceOwnerTag()

void PhosphorAnimation::PhosphorProfileRegistry::setLowPrecedenceOwnerTag ( const QString & tag)

Configure the owner tag whose entries should be treated as the lowest-precedence layer in resolveWithInheritance.

Set once per registry from the composition root (daemon / settings / editor) right after the registry is constructed, using the conventional kShellAnimationFamilySeedsOwnerTag. Empty (default) preserves single-pass walk semantics.

◆ snapshot()

QHash< QString, Profile > PhosphorAnimation::PhosphorProfileRegistry::snapshot ( ) const

Thread-safe copy of every NON-SEED (path → Profile) pair, owner tags discarded.

Seeds are a separate store and are not included; this is structural rather than a filter, so it agrees exactly with snapshotExcludingLowPrecedence. Prefer that name at a call site that serialises for an out-of-process consumer, since it says why the exclusion matters.

Note this does NOT agree with profileCount() or hasProfile(), which answer across both layers: a registry holding only seeds reports a non-zero count and an empty snapshot. For in-process resolution prefer resolveWithInheritance — it applies the parent-chain overlay the registry cannot encode in a flat snapshot.

◆ snapshotExcludingLowPrecedence()

QHash< QString, Profile > PhosphorAnimation::PhosphorProfileRegistry::snapshotExcludingLowPrecedence ( ) const

The same content as snapshot(), named for the reason a publisher needs it.

Publishers that serialize a ProfileTree for an out-of-process consumer MUST use this variant: tree overrides outrank the consumer's own baseline profile, so a flat snapshot would promote low-precedence seeds ABOVE the consumer's global profile — the exact shadowing setLowPrecedenceOwnerTag() exists to prevent (a window family seed would pin every window leg's duration and curve, turning the user's global animation settings into a no-op on the receiving side).

◆ unregisterProfile()

void PhosphorAnimation::PhosphorProfileRegistry::unregisterProfile ( const QString & path)

Remove path from the NON-SEED layer.

Fires profileChanged if there was one.

Deliberately does not touch the seed layer, so unregistering an override at a seeded path REVEALS the seed rather than dropping to library defaults — that reveal is the whole reason the two stores exist. A path that carries only a seed is therefore unaffected, and hasProfile() and resolve() keep answering for it afterwards. To remove a seed, use clearOwner() with the low-precedence tag, or clear().


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