on ab4ffb8 help sign in
90 lines 2.3 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 Screen;
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<Screen*>& list() const { return m_screens; }
60public Q_SLOTS:
61 void activateScreen(const QVariant& index);
63Q_SIGNALS:
64 void countChanged();
65 void activeScreenChanged();
67 void screenAdded(Screen* screen);
68 void screenRemoved(Screen* screen);
70private Q_SLOTS:
71 void onScreenAdded(qtmir::Screen *screen);
72 void onScreenRemoved(qtmir::Screen *screen);
74protected:
75 Screens(const Screens& other);
77 QVector<Screen*> m_screens;
78 QSharedPointer<qtmir::Screens> m_wrapped;
79};
81class ScreensProxy : public Screens
83public:
84 ScreensProxy(Screens*const screens);
86private:
87 const QPointer<Screens> m_original;
88};
90#endif // SCREENS_H