2 * Copyright (C) 2013, 2015 Canonical, Ltd.
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.
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.
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/>.
17#include "AccountsService.h"
18#include "MockUsersModel.h"
20#include <QLightDM/UsersModel>
23AccountsService::AccountsService(QObject* parent)
25 m_enableFingerprintIdentification(true),
26 m_enableLauncherWhileLocked(true),
27 m_enableIndicatorsWhileLocked(true),
29 m_statsWelcomeScreen(true),
31 m_failedFingerprintLogins(0),
33 m_demoEdgesCompleted(),
35 m_hereLicensePath(""),
36 m_usersModel(new MockUsersModel(this))
38 m_usersModel->setMockMode("full");
41QString AccountsService::user() const
46void AccountsService::setUser(const QString &user)
50 Q_EMIT passwordDisplayHintChanged();
51 Q_EMIT backgroundFileChanged();
54bool AccountsService::demoEdges() const
59void AccountsService::setDemoEdges(bool demoEdges)
61 m_demoEdges = demoEdges;
62 Q_EMIT demoEdgesChanged();
65QStringList AccountsService::demoEdgesCompleted() const
67 return m_demoEdgesCompleted;
70void AccountsService::markDemoEdgeCompleted(const QString &edge)
72 if (!m_demoEdgesCompleted.contains(edge)) {
73 m_demoEdgesCompleted << edge;
74 Q_EMIT demoEdgesCompletedChanged();
78void AccountsService::setDemoEdgesCompleted(const QStringList &demoEdgesCompleted)
80 m_demoEdgesCompleted = demoEdgesCompleted;
81 Q_EMIT demoEdgesCompletedChanged();
84bool AccountsService::enableFingerprintIdentification() const
86 return m_enableFingerprintIdentification;
89void AccountsService::setEnableFingerprintIdentification(bool enableFingerprintIdentification)
91 m_enableFingerprintIdentification = enableFingerprintIdentification;
92 Q_EMIT enableFingerprintIdentificationChanged();
95bool AccountsService::enableLauncherWhileLocked() const
97 return m_enableLauncherWhileLocked;
100void AccountsService::setEnableLauncherWhileLocked(bool enableLauncherWhileLocked)
102 m_enableLauncherWhileLocked = enableLauncherWhileLocked;
103 Q_EMIT enableLauncherWhileLockedChanged();
106bool AccountsService::enableIndicatorsWhileLocked() const
108 return m_enableIndicatorsWhileLocked;
111void AccountsService::setEnableIndicatorsWhileLocked(bool enableIndicatorsWhileLocked)
113 m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
114 Q_EMIT enableIndicatorsWhileLockedChanged();
117QString AccountsService::backgroundFile() const
119 if (!m_backgroundFile.isEmpty()) {
120 return m_backgroundFile;
123 // Check if our mock user has a background set in liblightdm
124 for (int i = 0; i < m_usersModel->count(); i++) {
125 if (m_usersModel->data(i, QLightDM::UsersModel::NameRole) == m_user) {
126 return m_usersModel->data(i, QLightDM::UsersModel::BackgroundPathRole).toString();
133void AccountsService::setBackgroundFile(const QString &backgroundFile)
135 m_backgroundFile = backgroundFile;
136 backgroundFileChanged();
139bool AccountsService::statsWelcomeScreen() const
141 return m_statsWelcomeScreen;
144void AccountsService::setStatsWelcomeScreen(bool statsWelcomeScreen)
146 m_statsWelcomeScreen = statsWelcomeScreen;
147 statsWelcomeScreenChanged();
150AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() const
152 if (m_user == "has-pin")
153 return PasswordDisplayHint::Numeric;
155 return PasswordDisplayHint::Keyboard;
158uint AccountsService::failedLogins() const
160 return m_failedLogins;
163void AccountsService::setFailedLogins(uint failedLogins)
165 m_failedLogins = failedLogins;
166 failedLoginsChanged();
169uint AccountsService::failedFingerprintLogins() const
171 return m_failedFingerprintLogins;
174void AccountsService::setFailedFingerprintLogins(uint failedFingerprintLogins)
176 m_failedFingerprintLogins = failedFingerprintLogins;
177 failedFingerprintLoginsChanged();
180bool AccountsService::hereEnabled() const
182 return m_hereEnabled;
185void AccountsService::setHereEnabled(bool enabled)
187 m_hereEnabled = enabled;
188 hereEnabledChanged();
191QString AccountsService::hereLicensePath() const
193 return m_hereLicensePath;
196void AccountsService::setHereLicensePath(const QString &path)
198 // Path should always be valid (this code is all synchronous)
200 m_hereLicensePath = QString::null;
201 } else if (path.isNull()) { // because qml collapses null and empty
202 m_hereLicensePath = "";
204 m_hereLicensePath = path;
206 hereLicensePathChanged();
209bool AccountsService::hereLicensePathValid() const
211 return !m_hereLicensePath.isNull();
214QString AccountsService::realName() const
219void AccountsService::setRealName(const QString &realName)
221 m_realName = realName;
222 Q_EMIT realNameChanged();
225QString AccountsService::email() const
230void AccountsService::setEmail(const QString &email)
233 Q_EMIT emailChanged();
236QStringList AccountsService::keymaps() const
238 if (!m_kbdMap.isEmpty()) {
242 return {QStringLiteral("us")};
245void AccountsService::setKeymaps(const QStringList &keymaps)
247 if (keymaps != m_kbdMap) {
249 Q_EMIT keymapsChanged();
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