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 "UsersModel.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 UsersModel(this))
40QString AccountsService::user() const
45void AccountsService::setUser(const QString &user)
49 Q_EMIT passwordDisplayHintChanged();
50 Q_EMIT backgroundFileChanged();
53bool AccountsService::demoEdges() const
58void AccountsService::setDemoEdges(bool demoEdges)
60 m_demoEdges = demoEdges;
61 Q_EMIT demoEdgesChanged();
64QStringList AccountsService::demoEdgesCompleted() const
66 return m_demoEdgesCompleted;
69void AccountsService::markDemoEdgeCompleted(const QString &edge)
71 if (!m_demoEdgesCompleted.contains(edge)) {
72 m_demoEdgesCompleted << edge;
73 Q_EMIT demoEdgesCompletedChanged();
77void AccountsService::setDemoEdgesCompleted(const QStringList &demoEdgesCompleted)
79 m_demoEdgesCompleted = demoEdgesCompleted;
80 Q_EMIT demoEdgesCompletedChanged();
83bool AccountsService::enableFingerprintIdentification() const
85 return m_enableFingerprintIdentification;
88void AccountsService::setEnableFingerprintIdentification(bool enableFingerprintIdentification)
90 m_enableFingerprintIdentification = enableFingerprintIdentification;
91 Q_EMIT enableFingerprintIdentificationChanged();
94bool AccountsService::enableLauncherWhileLocked() const
96 return m_enableLauncherWhileLocked;
99void AccountsService::setEnableLauncherWhileLocked(bool enableLauncherWhileLocked)
101 m_enableLauncherWhileLocked = enableLauncherWhileLocked;
102 Q_EMIT enableLauncherWhileLockedChanged();
105bool AccountsService::enableIndicatorsWhileLocked() const
107 return m_enableIndicatorsWhileLocked;
110void AccountsService::setEnableIndicatorsWhileLocked(bool enableIndicatorsWhileLocked)
112 m_enableIndicatorsWhileLocked = enableIndicatorsWhileLocked;
113 Q_EMIT enableIndicatorsWhileLockedChanged();
116QString AccountsService::backgroundFile() const
118 if (!m_backgroundFile.isEmpty()) {
119 return m_backgroundFile;
122 // Check if our mock user has a background set in liblightdm
123 for (int i = 0; i < m_usersModel->count(); i++) {
124 if (m_usersModel->data(i, QLightDM::UsersModel::NameRole) == m_user) {
125 return m_usersModel->data(i, QLightDM::UsersModel::BackgroundPathRole).toString();
132void AccountsService::setBackgroundFile(const QString &backgroundFile)
134 m_backgroundFile = backgroundFile;
135 backgroundFileChanged();
138bool AccountsService::statsWelcomeScreen() const
140 return m_statsWelcomeScreen;
143void AccountsService::setStatsWelcomeScreen(bool statsWelcomeScreen)
145 m_statsWelcomeScreen = statsWelcomeScreen;
146 statsWelcomeScreenChanged();
149AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() const
151 if (m_user == "has-pin")
152 return PasswordDisplayHint::Numeric;
154 return PasswordDisplayHint::Keyboard;
157uint AccountsService::failedLogins() const
159 return m_failedLogins;
162void AccountsService::setFailedLogins(uint failedLogins)
164 m_failedLogins = failedLogins;
165 failedLoginsChanged();
168uint AccountsService::failedFingerprintLogins() const
170 return m_failedFingerprintLogins;
173void AccountsService::setFailedFingerprintLogins(uint failedFingerprintLogins)
175 m_failedFingerprintLogins = failedFingerprintLogins;
176 failedFingerprintLoginsChanged();
179bool AccountsService::hereEnabled() const
181 return m_hereEnabled;
184void AccountsService::setHereEnabled(bool enabled)
186 m_hereEnabled = enabled;
187 hereEnabledChanged();
190QString AccountsService::hereLicensePath() const
192 return m_hereLicensePath;
195void AccountsService::setHereLicensePath(const QString &path)
197 // Path should always be valid (this code is all synchronous)
199 m_hereLicensePath = QString::null;
200 } else if (path.isNull()) { // because qml collapses null and empty
201 m_hereLicensePath = "";
203 m_hereLicensePath = path;
205 hereLicensePathChanged();
208bool AccountsService::hereLicensePathValid() const
210 return !m_hereLicensePath.isNull();
213QString AccountsService::realName() const
218void AccountsService::setRealName(const QString &realName)
220 m_realName = realName;
221 Q_EMIT realNameChanged();
224QString AccountsService::email() const
229void AccountsService::setEmail(const QString &email)
232 Q_EMIT emailChanged();
235QStringList AccountsService::keymaps() const
237 if (!m_kbdMap.isEmpty()) {
241 return {QStringLiteral("us")};
244void AccountsService::setKeymaps(const QStringList &keymaps)
246 if (keymaps != m_kbdMap) {
248 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