on c488c56 help sign in
unity8/tests/mocks/liblightdm/MockController.cpp
124 lines 3.0 kB history raw
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "MockController.h"
19static QLightDM::MockController *m_instance = nullptr;
21namespace QLightDM
24MockController::MockController(QObject *parent)
25 : QObject(parent)
26 , m_fullSessions(
27 {
28 {"ubuntu", "Ubuntu"},
29 {"ubuntu-2d", "Ubuntu 2D"},
30 {"gnome", "GNOME"},
31 {"gnome-classic", "GNOME Classic"},
32 {"gnome-flashback-compiz", "GNOME Flashback (Compiz)"},
33 {"gnome-flashback-metacity", "GNOME Flashback (Metacity)"},
34 {"gnome-wayland", "GNOME on Wayland"},
35 {"plasma", "Plasma"},
36 {"kde", "KDE" },
37 {"xterm", "Recovery Console"},
38 {"", "Unknown?"}
39 })
41 m_userMode = qgetenv("LIBLIGHTDM_MOCK_MODE");
42 if (m_userMode.isEmpty()) {
43 m_userMode = "full";
44 }
45 m_sessionMode = "full";
46 m_numSessions = numFullSessions();
49MockController::~MockController()
51 m_instance = nullptr;
54MockController *MockController::instance()
56 if (!m_instance) {
57 m_instance = new MockController;
58 }
59 return m_instance;
62QString MockController::selectUserHint() const
64 return m_selectUserHint;
67void MockController::setSelectUserHint(const QString &selectUserHint)
69 if (m_selectUserHint != selectUserHint) {
70 m_selectUserHint = selectUserHint;
71 Q_EMIT selectUserHintChanged();
72 }
75QString MockController::userMode() const
77 return m_userMode;
80void MockController::setUserMode(const QString &userMode)
82 if (m_userMode != userMode) {
83 m_userMode = userMode;
84 Q_EMIT userModeChanged();
85 }
88QString MockController::sessionMode() const
90 return m_sessionMode;
93void MockController::setSessionMode(const QString &sessionMode)
95 if (m_sessionMode != sessionMode) {
96 m_sessionMode = sessionMode;
97 Q_EMIT sessionModeChanged();
98 }
101const QList<MockController::SessionItem> &MockController::fullSessionItems() const
103 return m_fullSessions;
106int MockController::numFullSessions() const
108 return m_fullSessions.size();
111int MockController::numSessions() const
113 return m_numSessions;
116void MockController::setNumSessions(int numSessions)
118 if (m_numSessions != numSessions) {
119 m_numSessions = numSessions;
120 Q_EMIT numSessionsChanged();
121 }