on ccd07fa help sign in
93 lines 2.4 kB history raw
1/*
2 * Copyright (C) 2016 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 */
17#ifndef UNITY_SCREENS_H
18#define UNITY_SCREENS_H
20#include <QAbstractListModel>
21#include <QSharedPointer>
22#include <QPointer>
24namespace qtmir
26class Screen;
27class Screens;
30class ScreenInterface;
31class ScreensProxy;
33class Screens : public QAbstractListModel
35 Q_OBJECT
36 Q_PROPERTY(int count READ count NOTIFY countChanged)
37 Q_PROPERTY(QVariant activeScreen READ activeScreen WRITE activateScreen NOTIFY activeScreenChanged)
39public:
40 enum ItemRoles {
41 ScreenRole = Qt::UserRole + 1
42 };
44 explicit Screens(const QSharedPointer<qtmir::Screens>& model);
45 ~Screens();
47 Q_INVOKABLE ScreensProxy *createProxy();
48 Q_INVOKABLE void sync(Screens *proxy);
50 /* QAbstractItemModel */
51 QHash<int, QByteArray> roleNames() const override;
52 QVariant data(const QModelIndex &index, int role = ScreenRole) const override;
53 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
55 int count() const;
56 QVariant activeScreen() const;
58 const QVector<ScreenInterface*>& list() const { return m_screens; }
60 static Screens *self();
62public Q_SLOTS:
63 void activateScreen(const QVariant& index);
65Q_SIGNALS:
66 void countChanged();
67 void activeScreenChanged();
69 void screenAdded(ScreenInterface* screen);
70 void screenRemoved(ScreenInterface* screen);
72private Q_SLOTS:
73 void onScreenAdded(qtmir::Screen *screen);
74 void onScreenRemoved(qtmir::Screen *screen);
76protected:
77 Screens(const Screens& other);
79 QVector<ScreenInterface*> m_screens;
80 QSharedPointer<qtmir::Screens> m_wrapped;
81 static Screens* m_self;
82};
84class ScreensProxy : public Screens
86public:
87 ScreensProxy(Screens*const screens);
89private:
90 const QPointer<Screens> m_original;
91};
93#endif // SCREENS_H