Aggregates multiple ILayoutSource implementations behind one ILayoutSource interface.
More...
#include <phosphor-layout-api/include/PhosphorLayoutApi/CompositeLayoutSource.h>
Public Member Functions | |
| CompositeLayoutSource (QObject *parent=nullptr) | |
| ~CompositeLayoutSource () override | |
| void | addSource (ILayoutSource *source) |
| Append a child source to the aggregation. | |
| void | removeSource (ILayoutSource *source) |
Remove source from the aggregation. | |
| void | setSources (QVector< ILayoutSource * > sources) |
| Replace the child-source set in one shot. | |
| void | clearSources () |
| Drop every child source (without deleting — sources are borrowed). | |
| void | clearSourcesSilent () |
Drop every child source WITHOUT emitting contentsChanged. | |
| QVector< LayoutPreview > | availableLayouts () const override |
| Enumerate every layout this source can render. | |
| LayoutPreview | previewAt (const QString &id, int windowCount=DefaultPreviewWindowCount, const QSize &canvas={}) override |
| Produce a fully-realised preview for one layout entry. | |
Public Member Functions inherited from PhosphorLayout::ILayoutSource | |
| ~ILayoutSource () override | |
Additional Inherited Members | |
Signals inherited from PhosphorLayout::ILayoutSource | |
| void | contentsChanged () |
| Emitted whenever the set of layouts this source reports has changed (entries added, removed, or mutated — e.g. | |
Protected Member Functions inherited from PhosphorLayout::ILayoutSource | |
| ILayoutSource (QObject *parent=nullptr) | |
Aggregates multiple ILayoutSource implementations behind one ILayoutSource interface.
Use case: a consumer wants a unified view across providers (manual zone layouts via PhosphorZones::ZonesLayoutSource + autotile previews via PhosphorTiles::AutotileLayoutSource) but only wants to hold one pointer. Aggregation order is preserved — availableLayouts() returns the concatenation of each child's list, in the order they were added.
previewAt(id, ...) walks the children in order and returns the first non-empty result (children return an empty preview when they don't know the id, per the ILayoutSource contract). Two sources reporting the same id is a configuration bug — in practice the namespaces are disjoint (UUID vs autotile:...) so this doesn't occur in-tree.
The composite forwards each child's contentsChanged signal, so callers can listen at the composite level only.
Borrows the child sources — caller owns each one and must keep them alive for the composite's lifetime. addSource is idempotent (adding the same pointer twice is a no-op).
|
explicit |
|
override |
| void PhosphorLayout::CompositeLayoutSource::addSource | ( | ILayoutSource * | source | ) |
Append a child source to the aggregation.
Passing nullptr, or a source already added, is a harmless no-op. Emits contentsChanged once on successful insertion — callers performing bulk wiring should use setSources instead to avoid an N-signal storm.
|
overridevirtual |
Enumerate every layout this source can render.
The returned previews are populated enough for the picker UI to render rows (id, displayName, aspect-ratio class, autotile flag, optional algorithm metadata). For autotile entries the zones field is populated with a default-window-count preview; consumers wanting a different count call previewAt with the entry's id.
Implements PhosphorLayout::ILayoutSource.
| void PhosphorLayout::CompositeLayoutSource::clearSources | ( | ) |
Drop every child source (without deleting — sources are borrowed).
Handy for teardown paths that want to invalidate the composite before its children go out of scope.
| void PhosphorLayout::CompositeLayoutSource::clearSourcesSilent | ( | ) |
Drop every child source WITHOUT emitting contentsChanged.
Use from destructors / teardown paths where emitting a signal into potentially-mid-destruction subscribers is undesirable. LayoutSourceBundle's destructor uses this to break borrowed pointers safely without notifying observers whose own destructors may have already begun.
|
overridevirtual |
Produce a fully-realised preview for one layout entry.
id the LayoutPreview::id from availableLayouts windowCount for autotile entries, the window count to render the algorithm with. Ignored by manual sources (their zones are authored statically). Defaults to PhosphorLayout::DefaultPreviewWindowCount (4 — most picker thumbnails fit this nicely). canvas optional aspect-ratio + size hint. Sources that implement aspect-ratio filtering use this to set LayoutPreview::recommended; sources that don't ignore it. An empty QSize disables the hint.
Returns a default-constructed preview (empty id) when id is not known to this source. Caller checks result.id.isEmpty().
const ILayoutSource* cannot query previews — which matches the intent: querying a preview is an observable-effect operation on the source. Implements PhosphorLayout::ILayoutSource.
| void PhosphorLayout::CompositeLayoutSource::removeSource | ( | ILayoutSource * | source | ) |
Remove source from the aggregation.
No-op if source was never added. Does not take ownership (the composite only borrows), so the caller is responsible for deleting the source as usual. Only the two connections this composite made (forwarded contentsChanged and destroyed auto-drop) are torn down — unrelated connections the caller made on source are left intact.
| void PhosphorLayout::CompositeLayoutSource::setSources | ( | QVector< ILayoutSource * > | sources | ) |
Replace the child-source set in one shot.
Clears the existing entries, installs every non-null source from sources in order, and emits contentsChanged exactly once at the end. Intended for bulk wiring paths where incremental addSource calls would produce one signal per source.