2 * Copyright (C) 2015-2016 Canonical, Ltd.
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.
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.
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/>.
18 import QtQuick.Window 2.2
19 import Ubuntu.Components 1.3
20 import Ubuntu.Telephony 0.1 as Telephony
21 import "../Components"
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
34 property alias alphanumeric: loginList.alphanumeric
35 property alias userModel: loginList.model
36 property alias infographicModel: coverPage.infographicModel
37 property string sessionToStart
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)
49 signal emergencyCall()
56 function showFakePassword() {
57 loginList.showFakePassword();
60 function notifyAuthenticationFailed() {
61 loginList.showError();
64 function showErrorMessage(msg) {
65 coverPage.showErrorMessage(msg);
68 function forceShow() {
72 function tryToUnlock(toTheRight) {
73 var coverChanged = coverPage.shown;
74 lockscreen.maybeShow();
76 coverPage.hideRight();
85 lockscreen.maybeShow();
93 objectName: "lockscreen"
98 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
99 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
102 id: lockscreenBackground
103 objectName: "lockscreenBackground"
106 topMargin: root.backgroundTopMargin
108 source: root.background
111 // Darken background to match CoverPage
113 objectName: "lockscreenShade"
116 opacity: root.hasCustomBackground ? 0.4 : 0
121 objectName: "loginList"
124 horizontalCenter: parent.horizontalCenter
126 bottom: parent.bottom
129 boxVerticalOffset: units.gu(14)
130 enabled: !coverPage.shown && visible
131 visible: !delayedLockscreen.visible
135 onSelected: if (enabled) root.selected(index)
136 onResponded: root.responded(response)
140 id: delayedLockscreen
141 objectName: "delayedLockscreen"
143 visible: delayMinutes > 0
144 alphaNumeric: loginList.alphanumeric
147 function maybeShow() {
148 if (root.locked && !shown) {
157 opacity: coverPage.showProgress * 0.8
162 objectName: "coverPage"
163 height: parent.height
165 background: root.background
166 hasCustomBackground: root.hasCustomBackground
167 draggable: !root.waiting
168 onTease: root.tease()
171 onShowProgressChanged: {
172 if (showProgress === 0) {
173 if (lockscreen.shown) {
174 loginList.tryToUnlock();
184 topMargin: units.gu(2)
185 horizontalCenter: parent.horizontalCenter
192 visible: lockscreen.shown
195 anchors.left: parent.left
196 anchors.right: parent.right
197 anchors.top: parent.bottom
198 anchors.topMargin: - height * (1 - coverPage.showProgress)
199 - (inputMethod && inputMethod.visible ?
200 inputMethod.keyboardRectangle.height : 0)
203 color: UbuntuColors.porcelain // matches OSK background
208 text: i18n.tr("Cancel")
209 anchors.left: parent.left
210 anchors.leftMargin: units.gu(2)
211 anchors.top: parent.top
212 anchors.bottom: parent.bottom
213 verticalAlignment: Text.AlignVCenter
214 font.weight: Font.Light
216 color: UbuntuColors.slate
220 anchors.leftMargin: -units.gu(2)
221 anchors.rightMargin: -units.gu(2)
222 onClicked: coverPage.show()
227 objectName: "emergencyCallLabel"
228 text: callManager.hasCalls ? i18n.tr("Return to Call") : i18n.tr("Emergency")
229 anchors.right: parent.right
230 anchors.rightMargin: units.gu(2)
231 anchors.top: parent.top
232 anchors.bottom: parent.bottom
233 verticalAlignment: Text.AlignVCenter
234 font.weight: Font.Light
236 color: UbuntuColors.slate
237 // TODO: uncomment once bug 1616538 is fixed
238 // visible: telepathyHelper.ready && telepathyHelper.emergencyCallsAvailable
243 anchors.leftMargin: -units.gu(2)
244 anchors.rightMargin: -units.gu(2)
245 onClicked: root.emergencyCall()
250 // FIXME: It's difficult to keep something tied closely to the OSK (bug
251 // 1616163). But as a hack to avoid the background peeking out,
252 // we add an extra Rectangle that just serves to hide the background
253 // during OSK animations.
255 visible: bottomBar.visible
256 height: inputMethod && inputMethod.visible ?
257 inputMethod.keyboardRectangle.height : 0
258 anchors.bottom: parent.bottom
259 anchors.left: parent.left
260 anchors.right: parent.right
261 color: UbuntuColors.porcelain