2 * Copyright (C) 2016-2017 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/>.
21#include <qtmir/qtmir.h>
22#include <qtmir/screens.h>
23#include <QGuiApplication>
29Screens::Screens(QObject *parent)
30 : QAbstractListModel(parent)
33 int screenCount = qEnvironmentVariableIntValue("UNITY_MOCK_SCREEN_COUNT", &ok);
34 if (!ok) screenCount = 1;
35 QPoint lastPoint(0,0);
36 for (int i = 0; i < screenCount; ++i) {
37 auto screen = new Screen();
38 screen->m_id = qtmir::OutputId{i};
39 screen->m_active = i == 0;
40 screen->m_name = QString("Monitor %1").arg(i);
41 screen->m_position = QPoint(lastPoint.x(), lastPoint.y());
42 screen->m_sizes.append(new qtmir::ScreenMode(50, QSize(640,480)));
43 screen->m_sizes.append(new qtmir::ScreenMode(60, QSize(1280,1024)));
44 screen->m_sizes.append(new qtmir::ScreenMode(60, QSize(1440,900)));
45 screen->m_sizes.append(new qtmir::ScreenMode(60, QSize(1920,1080)));
46 screen->m_currentModeIndex = 3;
47 screen->m_physicalSize = QSize(800,568);
48 m_screenList.append(screen);
50 lastPoint.rx() += screen->m_sizes[screen->m_currentModeIndex]->size.width();
54QHash<int, QByteArray> Screens::roleNames() const
56 QHash<int, QByteArray> roles;
57 roles[ScreenRole] = "screen";
61QVariant Screens::data(const QModelIndex &index, int role) const
63 if (!index.isValid() || index.row() >= m_screenList.size()) {
69 return QVariant::fromValue(m_screenList.at(index.row()));
75int Screens::rowCount(const QModelIndex &) const
80int Screens::count() const
82 return m_screenList.size();
85QVariant Screens::activeScreen() const
87 for (int i = 0; i < m_screenList.count(); i++) {
88 if (m_screenList[i]->isActive()) return i;
93void Screens::activateScreen(const QVariant& vindex)
96 int index = vindex.toInt(&ok);
97 if (!ok || index < 0 || m_screenList.count() <= index) return;
99 auto screen = m_screenList.at(index);
100 screen->setActive(true);
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