on xenial help sign in
Support selectUserHint
e2c4923Michael Terry
plugins/LightDM/Greeter.cpp+6
@@ -78,6 +78,12 @@ bool Greeter::promptless() const
78 return d->promptless;
78 return d->promptless;
79}
79}
80
80
81+QString Greeter::selectUser() const
82+{
83+ Q_D(const Greeter);
84+ return d->m_greeter->selectUserHint();
85+}
86+
81void Greeter::authenticate(const QString &username)
87void Greeter::authenticate(const QString &username)
82{
88{
83 Q_D(Greeter);
89 Q_D(Greeter);
plugins/LightDM/Greeter.h+2
@@ -38,6 +38,7 @@ class Greeter : public QObject
38 Q_PROPERTY(bool authenticated READ isAuthenticated NOTIFY isAuthenticatedChanged)
38 Q_PROPERTY(bool authenticated READ isAuthenticated NOTIFY isAuthenticatedChanged)
39 Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
39 Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
40 Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
40 Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
41+ Q_PROPERTY(QString selectUser READ selectUser CONSTANT)
41
42
42public:
43public:
43 explicit Greeter(QObject* parent=0);
44 explicit Greeter(QObject* parent=0);
@@ -46,6 +47,7 @@ public:
46 bool isAuthenticated() const;
47 bool isAuthenticated() const;
47 QString authenticationUser() const;
48 QString authenticationUser() const;
48 bool promptless() const;
49 bool promptless() const;
50+ QString selectUser() const;
49
51
50public Q_SLOTS:
52public Q_SLOTS:
51 void authenticate(const QString &username=QString());
53 void authenticate(const QString &username=QString());
qml/Greeter/Greeter.qml+15−10
@@ -114,7 +114,8 @@ Showable {
114 id: d
114 id: d
115
115
116 readonly property bool multiUser: LightDMService.users.count > 1
116 readonly property bool multiUser: LightDMService.users.count > 1
117+ readonly property int selectUserIndex: d.getUserIndex(LightDMService.greeter.selectUser)
117− property int currentIndex
118+ property int currentIndex: Math.max(selectUserIndex, 0)
118 property bool waiting
119 property bool waiting
119
120
120 // We want 'launcherOffset' to animate down to zero. But not to animate
121 // We want 'launcherOffset' to animate down to zero. But not to animate
@@ -131,7 +132,19 @@ Showable {
131 UbuntuNumberAnimation {}
132 UbuntuNumberAnimation {}
132 }
133 }
133
134
135+ function getUserIndex(username) {
136+ // Find index for requested user, if it exists
137+ for (var i = 0; i < LightDMService.users.count; i++) {
138+ if (username === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {
139+ return i;
140+ }
141+ }
142+ return -1;
143+ }
144+
134 function selectUser(uid, reset) {
145 function selectUser(uid, reset) {
146+ if (uid < 0)
147+ return;
135 d.waiting = true;
148 d.waiting = true;
136 if (reset) {
149 if (reset) {
137 loader.item.reset();
150 loader.item.reset();
@@ -440,15 +453,7 @@ Showable {
440 }
453 }
441 }
454 }
442
455
443− onRequestAuthenticationUser: {
456+ onRequestAuthenticationUser: d.selectUser(d.getUserIndex(user), true)
444− // Find index for requested user, if it exists
445− for (var i = 0; i < LightDMService.users.count; i++) {
446− if (user === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {
447− d.selectUser(i, true);
448− return;
449− }
450− }
451− }
452 }
457 }
453
458
454 Connections {
459 Connections {