on fe9d37e help sign in
unity8/qml/Greeter/WideView.qml
209 lines 6.5 kB history raw
1/*
2 * Copyright (C) 2015-2016 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 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19import "." 0.1
21FocusScope {
22 id: root
23 focus: true
25 property alias background: coverPage.background
26 property alias backgroundTopMargin: coverPage.backgroundTopMargin
27 property alias hasCustomBackground: coverPage.hasCustomBackground
28 property alias dragHandleLeftMargin: coverPage.dragHandleLeftMargin
29 property alias infographicModel: coverPage.infographicModel
30 property alias launcherOffset: coverPage.launcherOffset
31 property alias currentIndex: loginList.currentIndex
32 property int delayMinutes // TODO
33 property alias alphanumeric: loginList.alphanumeric
34 property alias locked: loginList.locked
35 property alias sessionToStart: loginList.currentSession
36 property alias waiting: loginList.waiting
37 property var userModel // Set from outside
39 readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
40 readonly property bool fullyShown: coverPage.showProgress === 1
41 readonly property bool required: coverPage.required
43 // so that it can be replaced in tests with a mock object
44 property var inputMethod: Qt.inputMethod
46 signal selected(int index)
47 signal responded(string response)
48 signal tease()
49 signal emergencyCall() // unused
51 function notifyAuthenticationFailed() {
52 loginList.showError();
53 }
55 function forceShow() {
56 // Nothing to do, we are always fully shown
57 }
59 function tryToUnlock(toTheRight) {
60 if (root.locked) {
61 coverPage.show();
62 loginList.tryToUnlock();
63 return false;
64 } else {
65 var coverChanged = coverPage.shown;
66 if (toTheRight) {
67 coverPage.hideRight();
68 } else {
69 coverPage.hide();
70 }
71 return coverChanged;
72 }
73 }
75 function hide() {
76 coverPage.hide();
77 }
79 function showFakePassword() {
80 loginList.showFakePassword();
81 }
83 function showLastChance() {
84 // TODO
85 }
87 Rectangle {
88 anchors.fill: parent
89 color: "black"
90 opacity: coverPage.showProgress * 0.8
91 }
93 CoverPage {
94 id: coverPage
95 objectName: "coverPage"
96 height: parent.height
97 width: parent.width
98 draggable: !root.locked && !root.waiting
99 state: "LoginList"
101 infographics {
102 height: 0.75 * parent.height
103 anchors.leftMargin: loginList.x + loginList.width
104 }
106 onTease: root.tease()
108 onShowProgressChanged: {
109 if (showProgress === 0 && !root.locked) {
110 root.responded("");
111 }
112 }
114 LoginList {
115 id: loginList
116 objectName: "loginList"
118 width: units.gu(40)
119 anchors {
120 left: parent.left
121 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
122 top: parent.top
123 bottom: parent.bottom
124 }
126 boxVerticalOffset: (height - highlightedHeight -
127 (inputMethod && inputMethod.visible ?
128 inputMethod.keyboardRectangle.height : 0)) / 2
129 Behavior on boxVerticalOffset { UbuntuNumberAnimation {} }
131 model: root.userModel
132 onResponded: root.responded(response)
133 onSelected: root.selected(index)
134 onSessionChooserButtonClicked: parent.state = "SessionsList"
135 onCurrentIndexChanged: setCurrentSession()
137 Keys.forwardTo: [sessionChooserLoader.item]
139 Component.onCompleted: setCurrentSession()
141 function setCurrentSession() {
142 currentSession = LightDMService.users.data(currentIndex, LightDMService.userRoles.SessionRole);
143 }
144 }
146 Loader {
147 id: sessionChooserLoader
149 height: loginList.height
150 width: loginList.width
151 anchors {
152 left: parent.left
153 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
154 top: parent.top
155 }
157 active: false
159 onLoaded: sessionChooserLoader.item.forceActiveFocus();
160 Binding {
161 target: sessionChooserLoader.item
162 property: "initiallySelectedSession"
163 value: loginList.currentSession
164 }
166 Connections {
167 target: sessionChooserLoader.item
168 onSessionSelected: loginList.currentSession = sessionKey
169 onShowLoginList: {
170 coverPage.state = "LoginList"
171 loginList.tryToUnlock();
172 }
173 ignoreUnknownSignals: true
174 }
175 }
177 states: [
178 State {
179 name: "SessionsList"
180 PropertyChanges { target: loginList; opacity: 0 }
181 PropertyChanges { target: sessionChooserLoader;
182 active: true;
183 opacity: 1
184 source: "SessionsList.qml"
185 }
186 },
188 State {
189 name: "LoginList"
190 PropertyChanges { target: loginList; opacity: 1 }
191 PropertyChanges { target: sessionChooserLoader;
192 active: false;
193 opacity: 0
194 source: "";
195 }
196 }
197 ]
199 transitions: [
200 Transition {
201 from: "*"
202 to: "*"
203 UbuntuNumberAnimation {
204 property: "opacity";
205 }
206 }
207 ]
208 }