@@ -16,23 +16,27 @@
17import QtQuick 2.4
17import QtQuick 2.4
18import Ubuntu.Components 1.3
18import Ubuntu.Components 1.3
20FocusScope {
21FocusScope {
24+ property alias background: coverPage.background
25+ property alias backgroundTopMargin: coverPage.backgroundTopMargin
23 property alias dragHandleLeftMargin: coverPage.dragHandleLeftMargin
26 property alias dragHandleLeftMargin: coverPage.dragHandleLeftMargin
27+ property alias infographicModel: coverPage.infographicModel
24 property alias launcherOffset: coverPage.launcherOffset
28 property alias launcherOffset: coverPage.launcherOffset
25− property alias currentIndex: loginList.currentIndex
29+ property alias loginListShown: loginAreaLoader.loginListShown
30+ property int currentIndex // Set from outside
26 property int delayMinutes // TODO
31 property int delayMinutes // TODO
27− property alias backgroundTopMargin: coverPage.backgroundTopMargin
28− property alias background: coverPage.background
30 property bool alphanumeric // unused
32 property bool alphanumeric // unused
31− property alias userModel: loginList.model
33+ property bool locked
32− property alias infographicModel: coverPage.infographicModel
34+ property alias sessionToStart: loginAreaLoader.currentSession
35+ property var userModel // Set from outside
37+ readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
33 readonly property bool fullyShown: coverPage.showProgress === 1
38 readonly property bool fullyShown: coverPage.showProgress === 1
34 readonly property bool required: coverPage.required
39 readonly property bool required: coverPage.required
35− readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
37 // so that it can be replaced in tests with a mock object
41 // so that it can be replaced in tests with a mock object
38 property var inputMethod: Qt.inputMethod
42 property var inputMethod: Qt.inputMethod
@@ -42,38 +46,39 @@ FocusScope {
42 signal tease()
46 signal tease()
43 signal emergencyCall() // unused
47 signal emergencyCall() // unused
45− function showMessage(html) {
49+ /***** Functions that depend on LoginList being loaded *****/
46− loginList.showMessage(html);
50+ // A decorator to only call LoginList functions when its shown
51+ function ifLoginlistShownThen(f) {
53+ if (loginListShown) f.apply(this, arguments);
49− function showPrompt(text, isSecret, isDefaultPrompt) {
50− loginList.showPrompt(text, isSecret, isDefaultPrompt);
53− function showLastChance() {
57+ readonly property var notifyAuthenticationFailed: ifLoginlistShownThen(doNotifyAuthenticationFailed);
54− // TODO
58+ function doNotifyAuthenticationFailed() {
59+ loginAreaLoader.item.showError();
62+ readonly property var reset: ifLoginlistShownThen(doReset);
57− function hide() {
63+ function doReset() {
58− coverPage.hide();
64+ loginAreaLoader.item.reset();
61− function notifyAuthenticationSucceeded() {
67+ readonly property var showMessage: ifLoginlistShownThen(doShowMessage);
62− // Nothing needed
68+ function doShowMessage(html) {
69+ loginAreaLoader.item.showMessage(html);
65− function notifyAuthenticationFailed() {
72+ readonly property var showPrompt: ifLoginlistShownThen(doShowPrompt);
66− loginList.showError();
73+ function doShowPrompt(text, isSecret, isDefaultPrompt) {
74+ loginAreaLoader.item.showPrompt(text, isSecret, isDefaultPrompt);
69− function reset() {
77+ readonly property var tryToUnlock: ifLoginlistShownThen(doTryToUnlock);
73− function tryToUnlock(toTheRight) {
78+ function doTryToUnlock(toTheRight) {
74 if (root.locked) {
79 if (root.locked) {
75 coverPage.show();
80 coverPage.show();
76− loginList.tryToUnlock();
81+ loginAreaLoader.item.tryToUnlock();
77 return false;
82 return false;
79 var coverChanged = coverPage.shown;
84 var coverChanged = coverPage.shown;
@@ -86,6 +91,19 @@ FocusScope {
94+ /***** Functions that are agnostic of what object is loaded *****/
99+ function notifyAuthenticationSucceeded() {
103+ function showLastChance() {
89 Rectangle {
107 Rectangle {
90 anchors.fill: parent
108 anchors.fill: parent
91 color: "black"
109 color: "black"
@@ -101,7 +119,7 @@ FocusScope {
102 infographics {
120 infographics {
103 height: 0.75 * parent.height
121 height: 0.75 * parent.height
104− anchors.leftMargin: loginList.x + loginList.width
122+ anchors.leftMargin: loginAreaLoader.x + loginAreaLoader.width
107 onTease: root.tease()
125 onTease: root.tease()
@@ -112,24 +130,96 @@ FocusScope {
115− LoginList {
133+ Loader {
116− id: loginList
134+ id: loginAreaLoader
117− objectName: "loginList"
135+
136+ // True when LoginList is shown, false when SessionList is shown
137+ property bool loginListShown: true
138+ property bool sessionUpdated: false
139+ property string currentSession // Set as soon as LoginList is loaded
141+ source: loginListShown ? "LoginList.qml" : "SessionsList.qml"
142+ onSourceChanged: loadingAnimation.running = true
119 anchors {
144 anchors {
120 left: parent.left
145 left: parent.left
121 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
146 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
122 top: parent.top
147 top: parent.top
124 width: units.gu(29)
150 width: units.gu(29)
151+ height: inputMethod && inputMethod.visible ?
125− height: inputMethod && inputMethod.visible ? parent.height - inputMethod.keyboardRectangle.height
152+ parent.height - inputMethod.keyboardRectangle.height : parent.height
127 Behavior on height { UbuntuNumberAnimation {} }
154 Behavior on height { UbuntuNumberAnimation {} }
156+ UbuntuNumberAnimation {
157+ id: loadingAnimation
158+ target: loginAreaLoader.item
160+ from: loader.item.width
166+ target: loginAreaLoader.item
167+ property: "currentIndex"
168+ value: loginListShown ? root.currentIndex : null
172+ target: loginAreaLoader.item
129− locked: root.locked
174+ value: root.locked
178+ target: loginAreaLoader.item
180+ value: loginListShown ? root.userModel : null
183+ // Only inform LoginList if the session isn't the user's default session
184+ // because LoginList gets the default session on its own
186+ target: loginAreaLoader.item
187+ property: "selectedSession"
188+ value: loginListShown && loginAreaLoader.sessionUpdated ?
189+ loginAreaLoader.currentSession : null
193+ target: loginAreaLoader.item
194+ property: "initiallySelectedSession"
195+ value: !loginListShown ? loginAreaLoader.currentSession : null
199+ target: loginListShown ? loginAreaLoader.item : null
131− onSelected: root.selected(index)
200+ onSelected: root.selected(index)
132− onResponded: root.responded(response)
201+ onResponded: root.responded(response)
202+ // The initially selected session lags behind the component completion
203+ // so this provides the initial session name when available
204+ onLoginListSessionChanged: {
205+ if (loginListShown && !loginAreaLoader.sessionUpdated) {
206+ loginAreaLoader.currentSession = loginAreaLoader.item.currentSession
210+ onSessionChooserButtonClicked: loginListShown = false;
211+ ignoreUnknownSignals: true
215+ target: !loginListShown ? loginAreaLoader.item : null
216+ onSessionSelected: {
217+ loginAreaLoader.loginListShown = true
218+ loginAreaLoader.sessionUpdated = true
219+ loginAreaLoader.currentSession = sessionName
221+ ignoreUnknownSignals: true