Registry mapping profile path strings to Profile values. More...
#include <phosphor-animation/include/PhosphorAnimation/PhosphorProfileRegistry.h>
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. | |
| Profile | resolveWithInheritance (const QString &path, const QString &lowPrecedenceOwnerTag) const |
| 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. Fires profileChanged if it existed. | |
| 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 registered (path → Profile) pair, owner tags discarded. | |
| QHash< QString, Profile > | snapshotExcludingLowPrecedence () const |
| Like snapshot(), but omitting entries owned by the configured low-precedence tag (seed-style defaults). | |
| int | profileCount () const |
| Current path count. Thread-safe. | |
| bool | hasProfile (const QString &path) const |
Is path registered? 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. | |
Registry mapping profile path strings to Profile values.
Consumers register profiles here; settings reloads call registerProfile() to publish updates. Thread-safe (internal mutex).
|
explicit |
|
override |
|
delete |
| void PhosphorAnimation::PhosphorProfileRegistry::clear | ( | ) |
Clear the registry. Fires profilesReloaded().
| void PhosphorAnimation::PhosphorProfileRegistry::clearOwner | ( | const QString & | ownerTag | ) |
Remove every entry owned by ownerTag.
|
static |
Read the process-wide default; nullptr if none published yet.
| bool PhosphorAnimation::PhosphorProfileRegistry::hasProfile | ( | const QString & | path | ) | const |
Is path registered? Thread-safe.
|
delete |
| QString PhosphorAnimation::PhosphorProfileRegistry::ownerOf | ( | const QString & | path | ) | const |
Current owner tag for path, or empty string.
|
signal |
Fired at the end of a reloadFromOwner/clearOwner batch if any changes occurred.
|
signal |
Fired when a profile is registered, replaced, or unregistered.
| int PhosphorAnimation::PhosphorProfileRegistry::profileCount | ( | ) | const |
Current path count. Thread-safe.
|
signal |
Fired only on wholesale operations (reloadAll, clear).
| void PhosphorAnimation::PhosphorProfileRegistry::registerProfile | ( | const QString & | path, |
| const Profile & | profile | ||
| ) |
Register or replace the profile at path (direct/untagged owner).
| void PhosphorAnimation::PhosphorProfileRegistry::registerProfile | ( | const QString & | path, |
| const Profile & | profile, | ||
| const QString & | ownerTag | ||
| ) |
Register or replace at path, stamped with an owner tag.
| void PhosphorAnimation::PhosphorProfileRegistry::reloadAll | ( | const QHash< QString, Profile > & | profiles | ) |
Wholesale replace the entire registry. TEST-ONLY semantics.
| 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.
| 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.
| Profile PhosphorAnimation::PhosphorProfileRegistry::resolveWithInheritance | ( | const QString & | path | ) | const |
Resolve path with parent-chain inheritance.
Walks path → parent(path) → ... → "global", 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 (when lowPrecedenceOwnerTag is set). The walk runs in TWO passes: pass 1 overlays only entries owned by the low-precedence tag (seed-style defaults); pass 2 overlays everything else (Settings publishes, user JSONs). 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.
When lowPrecedenceOwnerTag is empty, the walk degrades to a single-pass deeper-wins overlay (the original semantics, kept for tests and consumers that don't use seed tagging).
| Profile PhosphorAnimation::PhosphorProfileRegistry::resolveWithInheritance | ( | const QString & | path, |
| const QString & | lowPrecedenceOwnerTag | ||
| ) | const |
|
static |
Publish registry as the process-wide default for QML resolution.
| 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.
| QHash< QString, Profile > PhosphorAnimation::PhosphorProfileRegistry::snapshot | ( | ) | const |
Thread-safe copy of every registered (path → Profile) pair, owner tags discarded.
Intended for publishers that need to serialize the merged per-event profile set out of process (e.g. the daemon broadcasting a ProfileTree to the kwin-effect over D-Bus). For in-process resolution prefer resolveWithInheritance — it applies the parent-chain overlay the registry cannot encode in a flat snapshot.
| QHash< QString, Profile > PhosphorAnimation::PhosphorProfileRegistry::snapshotExcludingLowPrecedence | ( | ) | const |
Like snapshot(), but omitting entries owned by the configured low-precedence tag (seed-style defaults).
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). With no low-precedence tag configured this is identical to snapshot().
| void PhosphorAnimation::PhosphorProfileRegistry::unregisterProfile | ( | const QString & | path | ) |
Remove path. Fires profileChanged if it existed.