on 5ea3c69 help sign in
unity8/qml/Greeter/WideView.qml
207 lines 6.4 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 objectName: "WideView"
25 focus: true
27 property alias background: coverPage.background
28 property alias backgroundTopMargin: coverPage.backgroundTopMargin
29 property alias hasCustomBackground: coverPage.hasCustomBackground
30 property alias dragHandleLeftMargin: coverPage.dragHandleLeftMargin
31 property alias infographicModel: coverPage.infographicModel
32 property alias launcherOffset: coverPage.launcherOffset
33 property alias currentIndex: loginList.currentIndex
34 property int delayMinutes // TODO
35 property alias alphanumeric: loginList.alphanumeric
36 property alias locked: loginList.locked
37 property alias waiting: loginList.waiting
38 property var userModel // Set from outside
40 readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
41 readonly property bool fullyShown: coverPage.showProgress === 1
42 readonly property bool required: coverPage.required
43 readonly property alias sessionToStart: loginList.currentSession
45 // so that it can be replaced in tests with a mock object
46 property var inputMethod: Qt.inputMethod
48 signal selected(int index)
49 signal responded(string response)
50 signal tease()
51 signal emergencyCall() // unused
53 function notifyAuthenticationFailed() {
54 loginList.showError();
55 }
57 function forceShow() {
58 // Nothing to do, we are always fully shown
59 }
61 function tryToUnlock(toTheRight) {
62 if (root.locked) {
63 coverPage.show();
64 loginList.tryToUnlock();
65 return false;
66 } else {
67 var coverChanged = coverPage.shown;
68 if (toTheRight) {
69 coverPage.hideRight();
70 } else {
71 coverPage.hide();
72 }
73 return coverChanged;
74 }
75 }
77 function hide() {
78 coverPage.hide();
79 }
81 function showFakePassword() {
82 loginList.showFakePassword();
83 }
85 Rectangle {
86 anchors.fill: parent
87 color: "black"
88 opacity: coverPage.showProgress * 0.8
89 }
91 CoverPage {
92 id: coverPage
93 objectName: "coverPage"
94 height: parent.height
95 width: parent.width
96 draggable: !root.locked && !root.waiting
97 state: "LoginList"
99 infographics {
100 height: 0.75 * parent.height
101 anchors.leftMargin: loginList.x + loginList.width
102 }
104 onTease: root.tease()
106 onShowProgressChanged: {
107 if (showProgress === 0 && !root.locked) {
108 root.responded("");
109 }
110 }
112 LoginList {
113 id: loginList
114 objectName: "loginList"
116 width: units.gu(40)
117 anchors {
118 left: parent.left
119 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
120 top: parent.top
121 bottom: parent.bottom
122 }
124 boxVerticalOffset: (height - highlightedHeight -
125 (inputMethod && inputMethod.visible ?
126 inputMethod.keyboardRectangle.height : 0)) / 2
127 Behavior on boxVerticalOffset { UbuntuNumberAnimation {} }
129 model: root.userModel
130 onResponded: root.responded(response)
131 onSelected: root.selected(index)
132 onSessionChooserButtonClicked: parent.state = "SessionsList"
133 onCurrentIndexChanged: setCurrentSession()
135 Keys.forwardTo: [sessionChooserLoader.item]
137 Component.onCompleted: setCurrentSession()
139 function setCurrentSession() {
140 currentSession = LightDMService.users.data(currentIndex, LightDMService.userRoles.SessionRole);
141 }
142 }
144 Loader {
145 id: sessionChooserLoader
147 height: loginList.height
148 width: loginList.width
150 anchors {
151 left: parent.left
152 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
153 top: parent.top
154 }
156 active: false
158 onLoaded: sessionChooserLoader.item.forceActiveFocus();
159 onActiveChanged: {
160 if (!active) return;
161 item.updateHighlight(loginList.currentSession);
162 }
164 Connections {
165 target: sessionChooserLoader.item
166 onSessionSelected: loginList.currentSession = sessionKey
167 onShowLoginList: {
168 coverPage.state = "LoginList"
169 loginList.tryToUnlock();
170 }
171 ignoreUnknownSignals: true
172 }
173 }
175 states: [
176 State {
177 name: "SessionsList"
178 PropertyChanges { target: loginList; opacity: 0 }
179 PropertyChanges { target: sessionChooserLoader;
180 active: true;
181 opacity: 1
182 source: "SessionsList.qml"
183 }
184 },
186 State {
187 name: "LoginList"
188 PropertyChanges { target: loginList; opacity: 1 }
189 PropertyChanges { target: sessionChooserLoader;
190 active: false;
191 opacity: 0
192 source: "";
193 }
194 }
195 ]
197 transitions: [
198 Transition {
199 from: "*"
200 to: "*"
201 UbuntuNumberAnimation {
202 property: "opacity";
203 }
204 }
205 ]
206 }