on 19a9ecd help sign in
unity8/qml/Greeter/NarrowView.qml
277 lines 8.8 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 QtQuick.Window 2.2
19import Ubuntu.Components 1.3
20import Ubuntu.Telephony 0.1 as Telephony
21import "../Components"
23FocusScope {
24 id: root
26 property alias dragHandleLeftMargin: coverPage.dragHandleLeftMargin
27 property alias launcherOffset: coverPage.launcherOffset
28 property alias currentIndex: loginList.currentIndex
29 property alias delayMinutes: delayedLockscreen.delayMinutes
30 property alias backgroundTopMargin: coverPage.backgroundTopMargin
31 property url background
32 property bool hasCustomBackground
33 property bool locked
34 property alias alphanumeric: loginList.alphanumeric
35 property alias userModel: loginList.model
36 property alias infographicModel: coverPage.infographicModel
37 property string sessionToStart
38 property bool waiting
39 readonly property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown
40 readonly property bool required: coverPage.required || lockscreen.required
41 readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
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()
51 function showLastChance() {
52 /* TODO: when we finish support for resetting device after too many
53 failed logins, we should re-add this popup.
54 var title = lockscreen.alphaNumeric ?
55 i18n.tr("Sorry, incorrect passphrase.") :
56 i18n.tr("Sorry, incorrect passcode.");
57 var text = i18n.tr("This will be your last attempt.") + " " +
58 (lockscreen.alphaNumeric ?
59 i18n.tr("If passphrase is entered incorrectly, your phone will conduct a factory reset and all personal data will be deleted.") :
60 i18n.tr("If passcode is entered incorrectly, your phone will conduct a factory reset and all personal data will be deleted."));
61 lockscreen.showInfoPopup(title, text);
62 */
63 }
65 function hide() {
66 lockscreen.hide();
67 coverPage.hide();
68 }
70 function showFakePassword() {
71 loginList.showFakePassword();
72 }
74 function notifyAuthenticationFailed() {
75 loginList.showError();
76 }
78 function showErrorMessage(msg) {
79 coverPage.showErrorMessage(msg);
80 }
82 function forceShow() {
83 coverPage.show();
84 }
86 function tryToUnlock(toTheRight) {
87 var coverChanged = coverPage.shown;
88 lockscreen.maybeShow();
89 if (toTheRight) {
90 coverPage.hideRight();
91 } else {
92 coverPage.hide();
93 }
94 return coverChanged;
95 }
97 onLockedChanged: {
98 if (locked) {
99 lockscreen.maybeShow();
100 } else {
101 lockscreen.hide();
102 }
103 }
105 Showable {
106 id: lockscreen
107 objectName: "lockscreen"
108 anchors.fill: parent
109 shown: false
110 opacity: 0
112 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
113 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
115 Wallpaper {
116 id: lockscreenBackground
117 objectName: "lockscreenBackground"
118 anchors {
119 fill: parent
120 topMargin: root.backgroundTopMargin
121 }
122 source: root.background
123 }
125 // Darken background to match CoverPage
126 Rectangle {
127 objectName: "lockscreenShade"
128 anchors.fill: parent
129 color: "black"
130 opacity: root.hasCustomBackground ? 0.4 : 0
131 }
133 LoginList {
134 id: loginList
135 objectName: "loginList"
137 anchors {
138 horizontalCenter: parent.horizontalCenter
139 top: parent.top
140 bottom: parent.bottom
141 }
142 width: units.gu(40)
143 boxVerticalOffset: units.gu(14)
144 enabled: !coverPage.shown && visible
145 visible: !delayedLockscreen.visible
147 locked: root.locked
149 onSelected: if (enabled) root.selected(index)
150 onResponded: root.responded(response)
151 }
153 DelayedLockscreen {
154 id: delayedLockscreen
155 objectName: "delayedLockscreen"
156 anchors.fill: parent
157 visible: delayMinutes > 0
158 alphaNumeric: loginList.alphanumeric
159 }
161 function maybeShow() {
162 if (root.locked && !shown) {
163 showNow();
164 }
165 }
166 }
168 Rectangle {
169 anchors.fill: parent
170 color: "black"
171 opacity: coverPage.showProgress * 0.8
172 }
174 CoverPage {
175 id: coverPage
176 objectName: "coverPage"
177 height: parent.height
178 width: parent.width
179 background: root.background
180 hasCustomBackground: root.hasCustomBackground
181 draggable: !root.waiting
182 onTease: root.tease()
183 onClicked: hide()
185 onShowProgressChanged: {
186 if (showProgress === 0) {
187 if (lockscreen.shown) {
188 loginList.tryToUnlock();
189 } else {
190 root.responded("");
191 }
192 }
193 }
195 Clock {
196 anchors {
197 top: parent.top
198 topMargin: units.gu(2)
199 horizontalCenter: parent.horizontalCenter
200 }
201 }
202 }
204 StyledItem {
205 id: bottomBar
206 visible: lockscreen.shown
207 height: units.gu(4)
209 anchors.left: parent.left
210 anchors.right: parent.right
211 anchors.top: parent.bottom
212 anchors.topMargin: - height * (1 - coverPage.showProgress)
213 - (inputMethod && inputMethod.visible ?
214 inputMethod.keyboardRectangle.height : 0)
216 Rectangle {
217 color: UbuntuColors.porcelain // matches OSK background
218 anchors.fill: parent
219 }
221 Label {
222 text: i18n.tr("Cancel")
223 anchors.left: parent.left
224 anchors.leftMargin: units.gu(2)
225 anchors.top: parent.top
226 anchors.bottom: parent.bottom
227 verticalAlignment: Text.AlignVCenter
228 font.weight: Font.Light
229 fontSize: "small"
230 color: UbuntuColors.slate
232 AbstractButton {
233 anchors.fill: parent
234 anchors.leftMargin: -units.gu(2)
235 anchors.rightMargin: -units.gu(2)
236 onClicked: coverPage.show()
237 }
238 }
240 Label {
241 objectName: "emergencyCallLabel"
242 text: callManager.hasCalls ? i18n.tr("Return to Call") : i18n.tr("Emergency")
243 anchors.right: parent.right
244 anchors.rightMargin: units.gu(2)
245 anchors.top: parent.top
246 anchors.bottom: parent.bottom
247 verticalAlignment: Text.AlignVCenter
248 font.weight: Font.Light
249 fontSize: "small"
250 color: UbuntuColors.slate
251 // TODO: uncomment once bug 1616538 is fixed
252 // visible: telepathyHelper.ready && telepathyHelper.emergencyCallsAvailable
253 enabled: visible
255 AbstractButton {
256 anchors.fill: parent
257 anchors.leftMargin: -units.gu(2)
258 anchors.rightMargin: -units.gu(2)
259 onClicked: root.emergencyCall()
260 }
261 }
262 }
264 // FIXME: It's difficult to keep something tied closely to the OSK (bug
265 // 1616163). But as a hack to avoid the background peeking out,
266 // we add an extra Rectangle that just serves to hide the background
267 // during OSK animations.
268 Rectangle {
269 visible: bottomBar.visible
270 height: inputMethod && inputMethod.visible ?
271 inputMethod.keyboardRectangle.height : 0
272 anchors.bottom: parent.bottom
273 anchors.left: parent.left
274 anchors.right: parent.right
275 color: UbuntuColors.porcelain
276 }