2 * Copyright (C) 2015 Canonical, Ltd.
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.
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.
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/>.
20#include <QGuiApplication>
24Q_DECLARE_METATYPE(QScreen*)
26Screens::Screens(QObject *parent) :
27 QAbstractListModel(parent)
30 int screenCount = qEnvironmentVariableIntValue("UNITY_MOCK_SCREEN_COUNT", &ok);
31 if (!ok) screenCount = 1;
32 QPoint lastPoint(0,0);
33 for (int i = 0; i < screenCount; ++i) {
34 auto screen = new Screen();
35 screen->enabled = i == 0;
37 screen->outputTypes = OutputTypes::LVDS;
39 screen->outputTypes = OutputTypes::HDMIA;
41 screen->name = QString("Monitor %1").arg(i);
42 screen->sizes = { QSize(640,480), QSize(1024,748), QSize(1280,1024), QSize(1440,900), QSize(1920,1080) };
43 screen->geometry = QRect(lastPoint.x(), lastPoint.y(), 1024, 786 );
44 m_screenList.append(screen);
46 lastPoint.rx() += screen->geometry.width();
50Screens::~Screens() noexcept
52 qDeleteAll(m_screenList);
56QHash<int, QByteArray> Screens::roleNames() const
58 QHash<int, QByteArray> roles;
59 roles[ScreenRole] = "screen";
60 roles[OutputTypeRole] = "outputType";
61 roles[EnabledRole] = "enabled";
62 roles[NameRole] = "name";
63 roles[ScaleRole] = "scale";
64 roles[FormFactorRole] = "formFactor";
65 roles[GeometryRole] = "geometry";
66 roles[SizesRole] = "sizes";
70QVariant Screens::data(const QModelIndex &index, int role) const
72 if (!index.isValid() || index.row() >= m_screenList.size()) {
78 return QVariant::fromValue(m_screenList.at(index.row())->qScreen);
80 return m_screenList.at(index.row())->outputTypes;
82 return m_screenList.at(index.row())->enabled;
84 return m_screenList.at(index.row())->name;
86 return m_screenList.at(index.row())->scale;
88 return m_screenList.at(index.row())->formFactor;
90 return m_screenList.at(index.row())->geometry;
94 auto availableSizes = m_screenList.at(index.row())->sizes;
95 Q_FOREACH(auto size, availableSizes) {
96 sizes.append(QVariant(size));
105int Screens::rowCount(const QModelIndex &) const
110int Screens::count() const
112 return m_screenList.size();
115void Screens::activateScreen(int)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list