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()
51
function showMessage(html) {
52
loginList.showMessage(html);
55
function showPrompt(text, isSecret, isDefaultPrompt) {
56
loginList.showPrompt(text, isSecret, isDefaultPrompt);
59
function showLastChance() {
60
/* TODO: when we finish support for resetting device after too many
61
failed logins, we should re-add this popup.
62
var title = lockscreen.alphaNumeric ?
63
i18n.tr("Sorry, incorrect passphrase.") :
64
i18n.tr("Sorry, incorrect passcode.");
65
var text = i18n.tr("This will be your last attempt.") + " " +
66
(lockscreen.alphaNumeric ?
67
i18n.tr("If passphrase is entered incorrectly, your phone will conduct a factory reset and all personal data will be deleted.") :
68
i18n.tr("If passcode is entered incorrectly, your phone will conduct a factory reset and all personal data will be deleted."));
69
lockscreen.showInfoPopup(title, text);
78
function notifyAuthenticationSucceeded(showFakePassword) {
79
if (showFakePassword) {
80
loginList.showFakePassword();
84
function notifyAuthenticationFailed() {
85
loginList.showError();
88
function showErrorMessage(msg) {
89
coverPage.showErrorMessage(msg);
92
function reset(forceShow) {
99
function tryToUnlock(toTheRight) {
100
var coverChanged = coverPage.shown;
101
lockscreen.maybeShow();
103
coverPage.hideRight();
112
lockscreen.maybeShow();
120
objectName: "lockscreen"
124
showAnimation: StandardAnimation { property: "opacity"; to: 1 }
125
hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
128
id: lockscreenBackground
129
objectName: "lockscreenBackground"
132
topMargin: root.backgroundTopMargin
134
source: root.background
137
// Darken background to match CoverPage
139
objectName: "lockscreenShade"
142
opacity: root.hasCustomBackground ? 0.4 : 0
147
objectName: "loginList"
150
horizontalCenter: parent.horizontalCenter
152
bottom: parent.bottom
155
boxVerticalOffset: units.gu(14)
156
enabled: !coverPage.shown && visible
157
visible: !delayedLockscreen.visible
161
onSelected: if (enabled) root.selected(index)
162
onResponded: root.responded(response)
166
id: delayedLockscreen
167
objectName: "delayedLockscreen"
169
visible: delayMinutes > 0
170
alphaNumeric: loginList.alphanumeric
173
function maybeShow() {
174
if (root.locked && !shown) {
183
opacity: coverPage.showProgress * 0.8
188
objectName: "coverPage"
189
height: parent.height
191
background: root.background
192
hasCustomBackground: root.hasCustomBackground
193
draggable: !root.waiting
194
onTease: root.tease()
197
onShowProgressChanged: {
198
if (showProgress === 1) {
200
} else if (showProgress === 0) {
201
loginList.tryToUnlock();
208
topMargin: units.gu(2)
209
horizontalCenter: parent.horizontalCenter
216
visible: lockscreen.shown
219
anchors.left: parent.left
220
anchors.right: parent.right
221
anchors.top: parent.bottom
222
anchors.topMargin: - height * (1 - coverPage.showProgress)
223
- (inputMethod && inputMethod.visible ?
224
inputMethod.keyboardRectangle.height : 0)
227
color: UbuntuColors.porcelain // matches OSK background
232
text: i18n.tr("Cancel")
233
anchors.left: parent.left
234
anchors.leftMargin: units.gu(2)
235
anchors.top: parent.top
236
anchors.bottom: parent.bottom
237
verticalAlignment: Text.AlignVCenter
238
font.weight: Font.Light
240
color: UbuntuColors.slate
244
anchors.leftMargin: -units.gu(2)
245
anchors.rightMargin: -units.gu(2)
246
onClicked: coverPage.show()
251
objectName: "emergencyCallLabel"
252
text: callManager.hasCalls ? i18n.tr("Return to Call") : i18n.tr("Emergency")
253
anchors.right: parent.right
254
anchors.rightMargin: units.gu(2)
255
anchors.top: parent.top
256
anchors.bottom: parent.bottom
257
verticalAlignment: Text.AlignVCenter
258
font.weight: Font.Light
260
color: UbuntuColors.slate
261
// TODO: uncomment once bug 1616538 is fixed
262
// visible: telepathyHelper.ready && telepathyHelper.emergencyCallsAvailable
267
anchors.leftMargin: -units.gu(2)
268
anchors.rightMargin: -units.gu(2)
269
onClicked: root.emergencyCall()
274
// FIXME: It's difficult to keep something tied closely to the OSK (bug
275
// 1616163). But as a hack to avoid the background peeking out,
276
// we add an extra Rectangle that just serves to hide the background
277
// during OSK animations.
279
visible: bottomBar.visible
280
height: inputMethod && inputMethod.visible ?
281
inputMethod.keyboardRectangle.height : 0
282
anchors.bottom: parent.bottom
283
anchors.left: parent.left
284
anchors.right: parent.right
285
color: UbuntuColors.porcelain