2 * Copyright (C) 2015-2016 Canonical Ltd.
3 * Copyright (C) 2021 UBports Foundation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19import QtQuick.Window 2.2
20import QtGraphicalEffects 1.12
21import Lomiri.Components 1.3
22import Lomiri.Telephony 0.1 as Telephony
28 property alias dragHandleLeftMargin: coverPage.dragHandleLeftMargin
29 property alias launcherOffset: coverPage.launcherOffset
30 property alias currentIndex: loginList.currentIndex
31 property alias delayMinutes: delayedLockscreen.delayMinutes
32 property real panelHeight
33 property url background
34 property real backgroundSourceSize
35 property bool hasCustomBackground
37 property alias alphanumeric: loginList.alphanumeric
38 property alias hasKeyboard: loginList.hasKeyboard
39 property alias userModel: loginList.model
40 property alias infographicModel: coverPage.infographicModel
41 property string sessionToStart
43 readonly property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown
44 readonly property bool required: coverPage.required || lockscreen.required
45 readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
47 property rect inputMethodRect
49 signal selected(int index)
50 signal responded(string response)
52 signal emergencyCall()
59 function showFakePassword() {
60 loginList.showFakePassword();
63 function notifyAuthenticationFailed() {
64 loginList.showError();
67 function showErrorMessage(msg) {
68 coverPage.showErrorMessage(msg);
71 function forceShow() {
75 function tryToUnlock(toTheRight) {
76 var coverChanged = coverPage.shown;
77 lockscreen.maybeShow();
79 coverPage.hideRight();
88 lockscreen.maybeShow();
94 Keys.onSpacePressed: coverPage.hide();
95 Keys.onReturnPressed: coverPage.hide();
96 Keys.onEnterPressed: coverPage.hide();
100 objectName: "lockscreen"
105 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
106 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
109 // In case background fails to load or doesn't cover the whole screen
116 id: lockscreenBackground
117 objectName: "lockscreenBackground"
121 source: root.background
122 sourceSize: root.backgroundSourceSize
125 // Darken background to match CoverPage
127 objectName: "lockscreenShade"
130 opacity: root.hasCustomBackground ? 0.4 : 0
135 objectName: "loginList"
138 horizontalCenter: parent.horizontalCenter
140 bottom: parent.bottom
143 boxVerticalOffset: units.gu(14)
144 enabled: !coverPage.shown && visible
145 visible: !delayedLockscreen.visible
149 onSelected: if (enabled) root.selected(index)
150 onResponded: root.responded(response)
154 id: delayedLockscreen
155 objectName: "delayedLockscreen"
157 visible: delayMinutes > 0
158 alphaNumeric: loginList.alphanumeric
161 function maybeShow() {
162 if (root.locked && !shown) {
171 opacity: coverPage.showProgress * 0.8
176 objectName: "coverPage"
177 height: parent.height
179 background: root.background
180 hasCustomBackground: root.hasCustomBackground
181 panelHeight: root.panelHeight
182 draggable: !root.waiting
183 onTease: root.tease()
185 backgroundSourceSize: root.backgroundSourceSize
187 onShowProgressChanged: {
188 if (showProgress === 0) {
189 if (lockscreen.shown) {
190 loginList.tryToUnlock();
200 topMargin: units.gu(2) + panelHeight
201 horizontalCenter: parent.horizontalCenter
208 visible: lockscreen.shown
211 anchors.left: parent.left
212 anchors.right: parent.right
213 anchors.top: parent.bottom
214 anchors.topMargin: - height * (1 - coverPage.showProgress)
215 - ( inputMethodRect.height )
218 text: i18n.tr("Cancel")
219 anchors.left: parent.left
220 anchors.leftMargin: units.gu(2)
221 anchors.top: parent.top
222 anchors.bottom: parent.bottom
223 verticalAlignment: Text.AlignVCenter
224 font.weight: Font.Light
226 color: theme.palette.normal.raisedSecondaryText
230 anchors.leftMargin: -units.gu(2)
231 anchors.rightMargin: -units.gu(2)
232 onClicked: coverPage.show()
237 objectName: "emergencyCallLabel"
238 text: callManager.hasCalls ? i18n.tr("Return to Call") : i18n.tr("Emergency")
239 anchors.right: parent.right
240 anchors.rightMargin: units.gu(2)
241 anchors.top: parent.top
242 anchors.bottom: parent.bottom
243 verticalAlignment: Text.AlignVCenter
244 font.weight: Font.Light
246 color: theme.palette.normal.raisedSecondaryText
247 // TODO: uncomment once bug 1616538 is fixed
248 // visible: telepathyHelper.ready && telepathyHelper.emergencyCallsAvailable
253 anchors.leftMargin: -units.gu(2)
254 anchors.rightMargin: -units.gu(2)
255 onClicked: root.emergencyCall()
260 // FIXME: It's difficult to keep something tied closely to the OSK (bug
261 // 1616163). But as a hack to avoid the background peeking out,
262 // we add an extra Rectangle that just serves to hide the background
263 // during OSK animations.
265 visible: bottomBar.visible
266 height: inputMethodRect.height
267 anchors.bottom: parent.bottom
268 anchors.left: parent.left
269 anchors.right: parent.right
270 color: LomiriColors.porcelain