@@ -1,162 +0,0 @@
1−/*
2− * Copyright (C) 2015 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef SCREENS_H
18−#define SCREENS_H
19−
20−#include <QAbstractListModel>
21−#include <QScreen>
22−#include <QQmlListProperty>
23−
24−class Screen;
25−
26−class Screens : public QAbstractListModel
27−{
28− Q_OBJECT
29−
30− Q_PROPERTY(int count READ count NOTIFY countChanged)
31−
32−public:
33− enum ItemRoles {
34− ScreenRole = Qt::UserRole + 1,
35− OutputTypeRole,
36− EnabledRole,
37− NameRole,
38− ScaleRole,
39− FormFactorRole,
40− GeometryRole,
41− SizesRole
42− };
43−
44− enum OutputTypes {
45− Unknown,
46− VGA,
47− DVII,
48− DVID,
49− DVIA,
50− Composite,
51− SVideo,
52− LVDS,
53− Component,
54− NinePinDIN,
55− DisplayPort,
56− HDMIA,
57− HDMIB,
58− TV,
59− EDP
60− };
61− Q_ENUM(OutputTypes)
62−
63− enum FormFactor {
64− FormFactorUnknown,
65− FormFactorPhone,
66− FormFactorTablet,
67− FormFactorMonitor,
68− FormFactorTV,
69− FormFactorProjector,
70− };
71−
72− explicit Screens(QObject *parent = 0);
73− virtual ~Screens() noexcept;
74−
75− /* QAbstractItemModel */
76− QHash<int, QByteArray> roleNames() const override;
77− QVariant data(const QModelIndex &index, int role = ScreenRole) const override;
78− int rowCount(const QModelIndex &parent = QModelIndex()) const override;
79−
80− int count() const;
81−
82−public Q_SLOTS:
83− void activateScreen(int index);
84−
85−Q_SIGNALS:
86− void countChanged();
87− void screenAdded(QScreen *screen);
88− void screenRemoved(QScreen *screen);
89−
90−private:
91− QList<Screen *> m_screenList;
92−};
93−
94−class ScreenMode : public QObject
95−{
96− Q_OBJECT
97− Q_PROPERTY(qreal refreshRate MEMBER refreshRate CONSTANT)
98− Q_PROPERTY(QSize size MEMBER size CONSTANT)
99−public:
100− ScreenMode() {}
101− ScreenMode(qreal refreshRate, QSize size):refreshRate(refreshRate),size(size) {}
102− ScreenMode(const ScreenMode& other)
103− : QObject(nullptr),
104− refreshRate{other.refreshRate},size{other.size}
105− {}
106−
107− qreal refreshRate;
108− QSize size;
109−};
110−
111−class Screen : public QObject
112−{
113− Q_OBJECT
114−
115− Q_PROPERTY(bool active MEMBER m_active NOTIFY activeChanged)
116−
117− Q_PROPERTY(bool used MEMBER m_used NOTIFY usedChanged)
118− Q_PROPERTY(QString name MEMBER m_name NOTIFY nameChanged)
119− Q_PROPERTY(Screens::OutputTypes outputType MEMBER m_outputType NOTIFY outputTypeChanged)
120− Q_PROPERTY(float scale MEMBER m_scale NOTIFY scaleChanged)
121− Q_PROPERTY(Screens::FormFactor formFactor MEMBER m_formFactor NOTIFY formFactorChanged)
122− Q_PROPERTY(QPoint position MEMBER m_position NOTIFY positionChanged)
123− Q_PROPERTY(uint currentModeIndex MEMBER m_currentModeIndex NOTIFY currentModeIndexChanged)
124− Q_PROPERTY(QQmlListProperty<ScreenMode> availableModes READ availableModes NOTIFY availableModesChanged)
125− Q_PROPERTY(QSizeF physicalSize MEMBER m_physicalSize NOTIFY physicalSizeChanged)
126−public:
127− Screen(QObject* parent = 0);
128− ~Screen();
129−
130− QQmlListProperty<ScreenMode> availableModes();
131−
132− Q_INVOKABLE Screen* beginConfiguration();
133− Q_INVOKABLE void applyConfiguration();
134−
135−Q_SIGNALS:
136− void activeChanged();
137− void usedChanged();
138− void nameChanged();
139− void outputTypeChanged();
140− void scaleChanged();
141− void formFactorChanged();
142− void positionChanged();
143− void currentModeIndexChanged();
144− void availableModesChanged();
145− void physicalSizeChanged();
146−
147−public:
148− bool m_active{false};
149− bool m_used{true};
150− QString m_name;
151− Screens::OutputTypes m_outputType{Screens::Unknown};
152− float m_scale{1.0};
153− Screens::FormFactor m_formFactor{Screens::FormFactorMonitor};
154− QPoint m_position;
155− uint m_currentModeIndex{0};
156− QList<ScreenMode*> m_sizes;
157− QSizeF m_physicalSize;
158−};
159−
160−Q_DECLARE_METATYPE(ScreenMode)
161−
162−#endif // SCREENS_H