Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PerScreenPanels.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorShell/phosphorshell_export.h>
7
8// Full definitions, not forward declarations, for both types this
9// header's moc surface exposes as pointer properties. Qt6 moc
10// auto-registers property metatypes and QMetaType static_asserts that a
11// pointed-to type is complete (or declared opaque) — a fwd decl trips
12// "Pointer Meta Types must either point to fully-defined types". Same
13// rationale as PipeWireHost.h.
14#include <QAbstractListModel>
15#include <QList>
16#include <QPointer>
17#include <QQmlComponent>
18#include <QQuickItem>
19
20namespace PhosphorShell {
21
91class PHOSPHORSHELL_EXPORT PerScreenPanels : public QQuickItem
92{
93 Q_OBJECT
94
95 Q_PROPERTY(QAbstractListModel* model READ model WRITE setModel NOTIFY modelChanged)
96 Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
98 Q_PROPERTY(int count READ count NOTIFY countChanged)
99 Q_CLASSINFO("DefaultProperty", "delegate")
100
101public:
102 explicit PerScreenPanels(QQuickItem* parent = nullptr);
104
105 [[nodiscard]] QAbstractListModel* model() const;
106 void setModel(QAbstractListModel* model);
107
108 [[nodiscard]] QQmlComponent* delegate() const;
109 void setDelegate(QQmlComponent* delegate);
110
111 [[nodiscard]] int count() const;
112
113Q_SIGNALS:
117
118protected:
119 void componentComplete() override;
120
121private:
122 void build();
125 void warnIfAlreadyBuilt(const char* property) const;
126
127 QPointer<QAbstractListModel> m_model;
128 QPointer<QQmlComponent> m_delegate;
129 // Latches in build(), unconditionally, so the one-shot contract holds
130 // even when a build produced nothing.
131 bool m_built = false;
132 // QPointer rows: an instance leaves this list's control the moment
133 // ShellEngine detaches it, and the Surface that adopts it may outlive
134 // or predecease us. Nothing here ever deletes an instance — the
135 // pointers exist so `count` and tests can observe what was built.
136 QList<QPointer<QObject>> m_instances;
137};
138
139} // namespace PhosphorShell
void setModel(QAbstractListModel *model)
QAbstractListModel * model() const
void componentComplete() override
PerScreenPanels(QQuickItem *parent=nullptr)
Number of instances created. Reads 0 until componentComplete.
void setDelegate(QQmlComponent *delegate)
QQmlComponent * delegate() const
Definition Environment.h:11