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/>.
17#include "MockScreens.h"
20#include <qtmir/screen.h>
24class MockScreen : public qtmir::Screen
30 m_sizes.append(new qtmir::ScreenMode(50, QSize(640,480)));
31 m_sizes.append(new qtmir::ScreenMode(60, QSize(1280,1024)));
32 m_sizes.append(new qtmir::ScreenMode(60, QSize(1440,900)));
33 m_sizes.append(new qtmir::ScreenMode(60, QSize(1920,1080)));
34 m_physicalSize = QSize(800,568);
37 qtmir::OutputId outputId() const override { return m_id; }
38 bool used() const override { return m_used; }
39 QString name() const override { return m_name; }
40 float scale() const override { return m_scale; }
41 QSizeF physicalSize() const override { return m_physicalSize; }
42 qtmir::FormFactor formFactor() const override { return m_formFactor; }
43 qtmir::OutputTypes outputType() const override { return m_outputType; }
44 MirPowerMode powerMode() const override { return m_powerMode; }
45 Qt::ScreenOrientation orientation() const override { return m_orientation; }
46 QPoint position() const override { return m_position; }
47 uint currentModeIndex() const override { return m_currentModeIndex; }
48 bool isActive() const override { return m_active; }
50 QQmlListProperty<qtmir::ScreenMode> availableModes() override {
51 return QQmlListProperty<qtmir::ScreenMode>(this, m_sizes);
54 void setActive(bool active) override {
55 if (m_active != active) {
57 Q_EMIT activeChanged(m_active);
61 QScreen* qscreen() const override { return nullptr; }
63 qtmir::ScreenConfiguration *beginConfiguration() const override {
64 auto config = new qtmir::ScreenConfiguration;
67 config->used = m_used;
68 config->topLeft = m_position;
69 config->currentModeIndex = m_currentModeIndex;
70 config->powerMode = m_powerMode;
71 config->scale = m_scale;
72 config->formFactor = m_formFactor;
76 bool applyConfiguration(qtmir::ScreenConfiguration *configuration) override {
77 m_used = configuration->used;
78 m_position = configuration->topLeft;
79 m_currentModeIndex = configuration->currentModeIndex;
80 m_powerMode = configuration->powerMode;
81 m_scale = configuration->scale;
82 m_formFactor = configuration->formFactor;
87 qtmir::OutputId m_id{0};
91 qtmir::OutputTypes m_outputType{qtmir::Unknown};
92 MirPowerMode m_powerMode{mir_power_mode_on};
93 Qt::ScreenOrientation m_orientation{Qt::PrimaryOrientation};
95 qtmir::FormFactor m_formFactor{qtmir::FormFactorMonitor};
97 uint m_currentModeIndex{0};
98 QList<qtmir::ScreenMode*> m_sizes;
99 QSizeF m_physicalSize;
103MockScreens::MockScreens()
106 int screenCount = qEnvironmentVariableIntValue("UNITY_MOCK_SCREEN_COUNT", &ok);
107 if (!ok) screenCount = 1;
108 QPoint lastPoint(0,0);
109 for (int i = 0; i < screenCount; ++i) {
110 auto screen = new MockScreen();
111 screen->m_id = qtmir::OutputId{i};
112 screen->m_active = i == 0;
113 screen->m_name = QString("Monitor %1").arg(i);
114 screen->m_position = QPoint(lastPoint.x(), lastPoint.y());
115 screen->m_currentModeIndex = 3;
116 m_mocks.append(screen);
118 lastPoint.rx() += screen->m_sizes[screen->m_currentModeIndex]->size.width();
122MockScreens::~MockScreens()
127QVector<qtmir::Screen *> MockScreens::screens() const
132qtmir::Screen *MockScreens::activeScreen() const
134 Q_FOREACH(auto screen, m_mocks) {
135 if (screen->isActive()) return screen;
140#include "MockScreens.moc"
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