Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
ScreenModel.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#include <QAbstractListModel>
9#include <QList>
10
11QT_BEGIN_NAMESPACE
12class QScreen;
13QT_END_NAMESPACE
14
15namespace PhosphorLayer {
16class IScreenProvider;
17} // namespace PhosphorLayer
18
19namespace PhosphorShell {
20
21// Not registered with QML directly — exposed via `PhosphorShell.screens`
22// (the ShellGlobal context-property). Construction is internal to
23// ShellEngine; QML can read it as a model but cannot instantiate it.
24class PHOSPHORSHELL_EXPORT ScreenModel : public QAbstractListModel
25{
26 Q_OBJECT
27
28public:
29 enum Role {
30 ScreenRole = Qt::UserRole + 1,
35 };
36 Q_ENUM(Role)
37
38 explicit ScreenModel(PhosphorLayer::IScreenProvider* provider, QObject* parent = nullptr);
39 ~ScreenModel() override;
40
41 int rowCount(const QModelIndex& parent = {}) const override;
42 QVariant data(const QModelIndex& index, int role) const override;
43 QHash<int, QByteArray> roleNames() const override;
44
45private Q_SLOTS:
46 void onScreensChanged();
47 void onPrimaryScreenChanged();
48
49private:
51 QList<QScreen*> m_screens;
52};
53
54} // namespace PhosphorShell
Source-of-truth interface for the available QScreen set.
Definition IScreenProvider.h:62
Definition ScreenModel.h:25
QVariant data(const QModelIndex &index, int role) const override
Role
Definition ScreenModel.h:29
@ WidthRole
Definition ScreenModel.h:32
@ NameRole
Definition ScreenModel.h:31
@ IsPrimaryRole
Definition ScreenModel.h:34
@ HeightRole
Definition ScreenModel.h:33
QHash< int, QByteArray > roleNames() const override
Definition SurfaceAnimator.h:26
Definition Environment.h:11