on xenial help sign in
Expand greeter demo support to include listing multiple users and specifying individual passwords and names.
commitaae00eaa3554530bfb4b5a677128eea3bccbaa11 authorMichael Terry <michael.terry@canonical.com> dateFri 7 Feb 2014, 10:43 (13 years ago) parent76db39ddc80861
7 files changed+13−426
tests/mocks/LightDM/demo/GreeterPrivate.cpp+2 tests/mocks/LightDM/demo/InfographicModelPrivate.cpp−91 tests/mocks/LightDM/demo/UsersModelPrivate.cpp+11−3 tests/mocks/LightDM/full/InfographicModelPrivate.cpp−182 tests/mocks/LightDM/single-passphrase/InfographicModelPrivate.cpp−61 tests/mocks/LightDM/single-pin/InfographicModelPrivate.cpp−61 tests/mocks/LightDM/single/InfographicModelPrivate.cpp−28
tests/mocks/LightDM/demo/GreeterPrivate.cpp+2
@@ -36,6 +36,7 @@ void GreeterPrivate::handleAuthenticate()
3636 Q_Q(Greeter);
3737
3838 QSettings settings(QDir::homePath() + "/.unity8-greeter-demo", QSettings::NativeFormat);
39+ settings.beginGroup(authenticationUser);
3940 QVariant password = settings.value("password", "none");
4041
4142 if (password == "pin") {
@@ -53,6 +54,7 @@ void GreeterPrivate::handleRespond(const QString &response)
5354 Q_Q(Greeter);
5455
5556 QSettings settings(QDir::homePath() + "/.unity8-greeter-demo", QSettings::NativeFormat);
57+ settings.beginGroup(authenticationUser);
5658 QVariant password = settings.value("password", "none");
5759
5860 QString passwordValue;
tests/mocks/LightDM/demo/InfographicModelPrivate.cppdeleted−91
@@ -1,91 +0,0 @@
1−/*
2− * Copyright (C) 2013 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− *
16− * Author: Pete Woods <pete.woods@canonical.com>
17− */
18−
19−#include "../InfographicModelPrivate.h"
20−
21−namespace QLightDM
22−{
23−
24−void InfographicModelPrivate::generateFakeData()
25−{
26− std::default_random_engine generator;
27− std::normal_distribution<qreal> distribution(0.5, 0.2);
28− auto rand = std::bind(distribution, generator);
29−
30− QColor orange(QColor::fromRgbF(0.9, 0.3, 0.1, 1.0));
31− QColor yellow(QColor::fromRgbF(1.0, 0.6, 0.0, 1.0));
32− QColor red(QColor::fromRgbF(0.8, 0.0, 0.0, 1.0));
33− QColor darkPurple(QColor::fromRgbF(0.5, 0.2, 0.3, 1.0));
34− QColor lightPurple(QColor::fromRgbF(0.8, 0.1, 0.8, 1.0));
35− QColor pink(QColor::fromRgbF(0.75, 0.13, 0.75));
36−
37− InfographicColorTheme orangeTheme(yellow, orange, red);
38− InfographicColorTheme yellowTheme(orange, yellow, orange);
39− InfographicColorTheme redTheme(red, red, red);
40− InfographicColorTheme darkPurpleTheme(lightPurple, darkPurple, pink);
41− InfographicColorTheme lightPurpleTheme(lightPurple, lightPurple,
42− lightPurple);
43− InfographicColorTheme pinkTheme(lightPurple, pink, darkPurple);
44−
45− {
46− QVariantList firstMonth;
47− while (firstMonth.size() < 17)
48− firstMonth.push_back(QVariant(rand()));
49− while (firstMonth.size() < 31)
50− firstMonth.push_back(QVariant());
51− QVariantList secondMonth;
52− while (secondMonth.size() < 31)
53− secondMonth.push_back(QVariant(rand()));
54− QSharedPointer<InfographicData> data(
55− new InfographicData("<b>52km</b> travelled", yellowTheme, firstMonth,
56− orangeTheme, secondMonth, this));
57− m_fakeData.insert("phablet", data);
58− }
59−
60− {
61− QVariantList firstMonth;
62− while (firstMonth.size() < 17)
63− firstMonth.push_back(QVariant(rand()));
64− while (firstMonth.size() < 31)
65− firstMonth.push_back(QVariant());
66− QVariantList secondMonth;
67− while (secondMonth.size() < 31)
68− secondMonth.push_back(QVariant(rand()));
69− QSharedPointer<InfographicData> data(
70− new InfographicData("<b>33</b> messages today", pinkTheme,
71− firstMonth, orangeTheme, secondMonth, this));
72− m_fakeData.insert("phablet", data);
73− }
74−
75− {
76− QVariantList firstMonth;
77− while (firstMonth.size() < 17)
78− firstMonth.push_back(QVariant(rand()));
79− while (firstMonth.size() < 31)
80− firstMonth.push_back(QVariant());
81− QVariantList secondMonth;
82− while (secondMonth.size() < 31)
83− secondMonth.push_back(QVariant(rand()));
84− QSharedPointer<InfographicData> data(
85− new InfographicData("<b>69</b> minutes talk time", darkPurpleTheme,
86− firstMonth, redTheme, secondMonth, this));
87− m_fakeData.insert("phablet", data);
88− }
89−}
90−
91−}
tests/mocks/LightDM/demo/UsersModelPrivate.cpp+11−3
@@ -18,16 +18,24 @@
1818
1919#include "../UsersModelPrivate.h"
2020
21+#include <QDir>
22+#include <QSettings>
23+#include <QStringList>
24+
2125namespace QLightDM
2226{
2327
2428UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
2529 : q_ptr(parent)
2630{
27− entries =
31+ QSettings settings(QDir::homePath() + "/.unity8-greeter-demo", QSettings::NativeFormat);
32+ QStringList users = settings.value("users", QStringList() << "phablet").toStringList();
33+
34+ Q_FOREACH(const QString &user, users)
2835 {
29− { "phablet", "Guest", 0, 0, false, false, 0, 0 },
30− };
36+ QString name = settings.value(user + "/name", user[0].toUpper() + user.mid(1)).toString();
37+ entries.append({user, name, 0, 0, false, false, 0, 0});
38+ }
3139}
3240
3341}
tests/mocks/LightDM/full/InfographicModelPrivate.cppdeleted−182
@@ -1,182 +0,0 @@
1−/*
2− * Copyright (C) 2013 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− *
16− * Author: Pete Woods <pete.woods@canonical.com>
17− */
18−
19−#include "../InfographicModelPrivate.h"
20−
21−namespace QLightDM
22−{
23−
24−void InfographicModelPrivate::generateFakeData()
25−{
26− std::default_random_engine generator;
27− std::normal_distribution<qreal> distribution(0.5, 0.2);
28− auto rand = std::bind(distribution, generator);
29−
30− QColor orange = QColor::fromRgbF(0.9, 0.3, 0.1, 1.0);
31− QColor yellow = QColor::fromRgbF(1.0, 0.6, 0.0, 1.0);
32− QColor red = QColor::fromRgbF(0.8, 0.0, 0.0, 1.0);
33− QColor darkPurple = QColor::fromRgbF(0.5, 0.2, 0.3, 1.0);
34− QColor lightPurple = QColor::fromRgbF(0.8, 0.1, 0.8, 1.0);
35− QColor pink(QColor::fromRgbF(0.75, 0.13, 0.75));
36−
37− InfographicColorTheme orangeTheme(orange, orange, orange);
38− InfographicColorTheme yellowTheme(yellow, yellow, yellow);
39− InfographicColorTheme redTheme(red, red, red);
40− InfographicColorTheme darkPurpleTheme(darkPurple, darkPurple, darkPurple);
41− InfographicColorTheme lightPurpleTheme(lightPurple, lightPurple,
42− lightPurple);
43− InfographicColorTheme pinkTheme(pink, pink, pink);
44−
45− {
46− QVariantList firstMonth;
47− while (firstMonth.size() < 17)
48− firstMonth.push_back(QVariant(rand()));
49− while (firstMonth.size() < 31)
50− firstMonth.push_back(QVariant());
51− QVariantList secondMonth;
52− while (secondMonth.size() < 31)
53− secondMonth.push_back(QVariant(rand()));
54− QSharedPointer<InfographicData> data(
55− new InfographicData("<b>5km</b> travelled", yellowTheme,
56− firstMonth, orangeTheme, secondMonth, this));
57− m_fakeData.insert("has-password", data);
58− }
59−
60− {
61− QVariantList firstMonth;
62− while (firstMonth.size() < 17)
63− firstMonth.push_back(QVariant(rand()));
64− while (firstMonth.size() < 31)
65− firstMonth.push_back(QVariant());
66− QVariantList secondMonth;
67− while (secondMonth.size() < 31)
68− secondMonth.push_back(QVariant(rand()));
69− QSharedPointer<InfographicData> data(
70− new InfographicData("<b>33</b> messages today", pinkTheme,
71− firstMonth, orangeTheme, secondMonth, this));
72− m_fakeData.insert("has-password", data);
73− }
74−
75− {
76− QVariantList firstMonth;
77− while (firstMonth.size() < 17)
78− firstMonth.push_back(QVariant(rand()));
79− while (firstMonth.size() < 31)
80− firstMonth.push_back(QVariant());
81− QVariantList secondMonth;
82− while (secondMonth.size() < 31)
83− secondMonth.push_back(QVariant(rand()));
84− QSharedPointer<InfographicData> data(
85− new InfographicData("<b>19</b> minutes talk time", orangeTheme,
86− firstMonth, redTheme, secondMonth, this));
87− m_fakeData.insert("has-password", data);
88− }
89−
90− {
91− QVariantList firstMonth;
92− while (firstMonth.size() < 17)
93− firstMonth.push_back(QVariant(rand()));
94− while (firstMonth.size() < 31)
95− firstMonth.push_back(QVariant());
96− QVariantList secondMonth;
97− while (secondMonth.size() < 31)
98− secondMonth.push_back(QVariant(rand()));
99− QSharedPointer<InfographicData> data(
100− new InfographicData("<b>5km</b> travelled", redTheme,
101− firstMonth, darkPurpleTheme, secondMonth, this));
102− m_fakeData.insert("no-password", data);
103− }
104−
105− {
106− QVariantList firstMonth;
107− while (firstMonth.size() < 17)
108− firstMonth.push_back(QVariant(rand()));
109− while (firstMonth.size() < 31)
110− firstMonth.push_back(QVariant());
111− QVariantList secondMonth;
112− while (secondMonth.size() < 31)
113− secondMonth.push_back(QVariant(rand()));
114− QSharedPointer<InfographicData> data(
115− new InfographicData("<b>33</b> messages today",
116− lightPurpleTheme, firstMonth, darkPurpleTheme,
117− secondMonth, this));
118− m_fakeData.insert("no-password", data);
119− }
120−
121− {
122− QVariantList firstMonth;
123− while (firstMonth.size() < 17)
124− firstMonth.push_back(QVariant(rand()));
125− while (firstMonth.size() < 31)
126− firstMonth.push_back(QVariant());
127− QVariantList secondMonth;
128− while (secondMonth.size() < 31)
129− secondMonth.push_back(QVariant());
130− QSharedPointer<InfographicData> data(
131− new InfographicData("<b>19</b> minutes talk time", orangeTheme,
132− firstMonth, redTheme, secondMonth, this));
133− m_fakeData.insert("no-password", data);
134− }
135−
136− {
137− QVariantList firstMonth;
138− while (firstMonth.size() < 29)
139− firstMonth.push_back(QVariant(rand()));
140− while (firstMonth.size() < 31)
141− firstMonth.push_back(QVariant());
142− QVariantList secondMonth;
143− while (secondMonth.size() < 31)
144− secondMonth.push_back(QVariant(rand()));
145− QSharedPointer<InfographicData> data(
146− new InfographicData("<b>5km</b> travelled", redTheme,
147− firstMonth, darkPurpleTheme, secondMonth, this));
148− m_fakeData.insert("empty-name", data);
149− }
150−
151− {
152− QVariantList firstMonth;
153− while (firstMonth.size() < 29)
154− firstMonth.push_back(QVariant(rand()));
155− while (firstMonth.size() < 31)
156− firstMonth.push_back(QVariant());
157− QVariantList secondMonth;
158− while (secondMonth.size() < 31)
159− secondMonth.push_back(QVariant(rand()));
160− QSharedPointer<InfographicData> data(
161− new InfographicData("<b>33</b> messages today", yellowTheme,
162− firstMonth, orangeTheme, secondMonth, this));
163− m_fakeData.insert("empty-name", data);
164− }
165−
166− {
167− QVariantList firstMonth;
168− while (firstMonth.size() < 29)
169− firstMonth.push_back(QVariant(rand()));
170− while (firstMonth.size() < 31)
171− firstMonth.push_back(QVariant());
172− QVariantList secondMonth;
173− while (secondMonth.size() < 31)
174− secondMonth.push_back(QVariant());
175− QSharedPointer<InfographicData> data(
176− new InfographicData("<b>19</b> minutes talk time", pinkTheme,
177− firstMonth, orangeTheme, secondMonth, this));
178− m_fakeData.insert("empty-name", data);
179− }
180−}
181−
182−}
tests/mocks/LightDM/single-passphrase/InfographicModelPrivate.cppdeleted−61
@@ -1,61 +0,0 @@
1−/*
2− * Copyright (C) 2013 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− *
16− * Author: Pete Woods <pete.woods@canonical.com>
17− */
18−
19−#include "../InfographicModelPrivate.h"
20−
21−namespace QLightDM
22−{
23−
24−void InfographicModelPrivate::generateFakeData()
25−{
26− std::default_random_engine generator;
27− std::normal_distribution<qreal> distribution(0.5, 0.2);
28− auto rand = std::bind(distribution, generator);
29−
30− QColor orange = QColor::fromRgbF(0.9, 0.3, 0.1, 1.0);
31− QColor yellow = QColor::fromRgbF(1.0, 0.6, 0.0, 1.0);
32− QColor red = QColor::fromRgbF(0.8, 0.0, 0.0, 1.0);
33− QColor darkPurple = QColor::fromRgbF(0.5, 0.2, 0.3, 1.0);
34− QColor lightPurple = QColor::fromRgbF(0.8, 0.1, 0.8, 1.0);
35− QColor pink(QColor::fromRgbF(0.75, 0.13, 0.75));
36−
37− InfographicColorTheme orangeTheme(orange, orange, orange);
38− InfographicColorTheme yellowTheme(yellow, yellow, yellow);
39− InfographicColorTheme redTheme(red, red, red);
40− InfographicColorTheme darkPurpleTheme(darkPurple, darkPurple, darkPurple);
41− InfographicColorTheme lightPurpleTheme(lightPurple, lightPurple,
42− lightPurple);
43− InfographicColorTheme pinkTheme(pink, pink, pink);
44−
45− {
46− QVariantList firstMonth;
47− while (firstMonth.size() < 17)
48− firstMonth.push_back(QVariant(rand()));
49− while (firstMonth.size() < 31)
50− firstMonth.push_back(QVariant());
51− QVariantList secondMonth;
52− while (secondMonth.size() < 31)
53− secondMonth.push_back(QVariant(rand()));
54− QSharedPointer<InfographicData> data(
55− new InfographicData("<b>5km</b> travelled", yellowTheme,
56− firstMonth, orangeTheme, secondMonth, this));
57− m_fakeData.insert("has-pin", data);
58− }
59−}
60−
61−}
tests/mocks/LightDM/single-pin/InfographicModelPrivate.cppdeleted−61
@@ -1,61 +0,0 @@
1−/*
2− * Copyright (C) 2013 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− *
16− * Author: Pete Woods <pete.woods@canonical.com>
17− */
18−
19−#include "../InfographicModelPrivate.h"
20−
21−namespace QLightDM
22−{
23−
24−void InfographicModelPrivate::generateFakeData()
25−{
26− std::default_random_engine generator;
27− std::normal_distribution<qreal> distribution(0.5, 0.2);
28− auto rand = std::bind(distribution, generator);
29−
30− QColor orange = QColor::fromRgbF(0.9, 0.3, 0.1, 1.0);
31− QColor yellow = QColor::fromRgbF(1.0, 0.6, 0.0, 1.0);
32− QColor red = QColor::fromRgbF(0.8, 0.0, 0.0, 1.0);
33− QColor darkPurple = QColor::fromRgbF(0.5, 0.2, 0.3, 1.0);
34− QColor lightPurple = QColor::fromRgbF(0.8, 0.1, 0.8, 1.0);
35− QColor pink(QColor::fromRgbF(0.75, 0.13, 0.75));
36−
37− InfographicColorTheme orangeTheme(orange, orange, orange);
38− InfographicColorTheme yellowTheme(yellow, yellow, yellow);
39− InfographicColorTheme redTheme(red, red, red);
40− InfographicColorTheme darkPurpleTheme(darkPurple, darkPurple, darkPurple);
41− InfographicColorTheme lightPurpleTheme(lightPurple, lightPurple,
42− lightPurple);
43− InfographicColorTheme pinkTheme(pink, pink, pink);
44−
45− {
46− QVariantList firstMonth;
47− while (firstMonth.size() < 17)
48− firstMonth.push_back(QVariant(rand()));
49− while (firstMonth.size() < 31)
50− firstMonth.push_back(QVariant());
51− QVariantList secondMonth;
52− while (secondMonth.size() < 31)
53− secondMonth.push_back(QVariant(rand()));
54− QSharedPointer<InfographicData> data(
55− new InfographicData("<b>5km</b> travelled", yellowTheme,
56− firstMonth, orangeTheme, secondMonth, this));
57− m_fakeData.insert("has-pin", data);
58− }
59−}
60−
61−}
tests/mocks/LightDM/single/InfographicModelPrivate.cppdeleted−28
@@ -1,28 +0,0 @@
1−/*
2− * Copyright (C) 2013 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− *
16− * Author: Pete Woods <pete.woods@canonical.com>
17− */
18−
19−#include "../InfographicModelPrivate.h"
20−
21−namespace QLightDM
22−{
23−
24−void InfographicModelPrivate::generateFakeData()
25−{
26−}
27−
28−}