2 * Copyright (C) 2013-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 QtGraphicalEffects 1.12
20import Lomiri.Components 1.3
21import Lomiri.Gestures 0.1
27 property real dragHandleLeftMargin
28 property real launcherOffset
29 property alias background: greeterBackground.source
30 property alias backgroundSourceSize: greeterBackground.sourceSize
31 property alias hasCustomBackground: backgroundShade.visible
32 property real panelHeight
33 property var infographicModel
34 property bool draggable: true
36 property alias infographics: infographics
38 property alias blurAreaHeight: loginBoxEffects.height
39 property alias blurAreaWidth: loginBoxEffects.width
40 property alias blurAreaX: loginBoxEffects.x
41 property alias blurAreaY: loginBoxEffects.y
43 readonly property real showProgress: MathUtils.clamp((width - Math.abs(x + launcherOffset)) / width, 0, 1)
48 function hideRight() {
49 d.forceRightOnNextHideAnimation = true;
53 function showErrorMessage(msg) {
55 showLabelAnimation.start();
56 errorMessageAnimation.start();
61 property bool forceRightOnNextHideAnimation: false
62 property string errorMessage
65 prepareToHide: function () {
66 hideTranslation.from = root.x + translation.x
67 hideTranslation.to = root.x > 0 || d.forceRightOnNextHideAnimation ? root.width : -root.width;
68 d.forceRightOnNextHideAnimation = false;
71 // We don't directly bind "x" because that's owned by the DragHandle. So
72 // instead, we can get a little extra horizontal push by using transforms.
73 transform: Translate { id: translation; x: root.draggable ? launcherOffset : 0 }
75 // Eat events elsewhere on the coverpage, except mouse clicks which we pass
76 // up (they are used in the NarrowView to hide the cover page)
79 onClicked: root.clicked()
88 // In case background fails to load
96 objectName: "greeterBackground"
110 sourceItem: greeterBackground
111 anchors.centerIn: loginBoxEffects
112 width: loginBoxEffects.width
113 height: loginBoxEffects.height
114 sourceRect: Qt.rect(x,y, width, height)
119 anchors.fill: effectSource
122 transparentBorder: true
125 // Darkens wallpaper so that we can read text on it and see infographic
128 objectName: "backgroundShade"
137 objectName: "infographics"
138 model: root.infographicModel
139 clip: true // clip large data bubbles
142 topMargin: root.panelHeight
144 bottom: parent.bottom
152 objectName: "swipeHint"
153 property real baseOpacity: 0.5
155 anchors.horizontalCenter: parent.horizontalCenter
156 anchors.bottom: parent.bottom
157 anchors.bottomMargin: units.gu(5)
158 text: "《 " + (d.errorMessage ? d.errorMessage : i18n.tr("Unlock")) + " 》"
160 font.weight: Font.Light
162 readonly property var opacityAnimation: showLabelAnimation // for testing
164 SequentialAnimation on opacity {
165 id: showLabelAnimation
171 to: swipeHint.baseOpacity
172 duration: LomiriAnimation.SleepyDuration
174 PauseAnimation { duration: LomiriAnimation.BriskDuration }
176 from: swipeHint.baseOpacity
178 duration: LomiriAnimation.SleepyDuration
188 WrongPasswordAnimation {
189 id: errorMessageAnimation
190 objectName: "errorMessageAnimation"
196 objectName: "coverPageDragHandle"
198 anchors.leftMargin: root.dragHandleLeftMargin
199 enabled: root.draggable
200 direction: Direction.Horizontal
205 showLabelAnimation.start();
212 anchors.left: parent.right
213 anchors.top: parent.top
214 anchors.bottom: parent.bottom
216 source: "../graphics/dropshadow_right.png"
221 anchors.right: parent.left
222 anchors.top: parent.top
223 anchors.bottom: parent.bottom
225 source: "../graphics/dropshadow_left.png"
231 property bool enabled: false
233 if (enabled === __enabled) {
239 value = Qt.binding(function() { return root.width; })
241 value = Qt.binding(function() { return -root.width; })
248 property bool __enabled: false
255 hideAnimation: SequentialAnimation {
257 objectName: "hideAnimation"
258 property var target // unused, here to silence Showable warning
264 PropertyAction { target: root; property: "visible"; value: false }
265 PropertyAction { target: positionLock; property: "enabled"; value: true }
268 showAnimation: SequentialAnimation {
270 objectName: "showAnimation"
271 property var target // unused, here to silence Showable warning
272 PropertyAction { target: root; property: "visible"; value: true }
273 PropertyAction { target: positionLock; property: "enabled"; value: false }
278 duration: LomiriAnimation.FastDuration