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/>.
19 import QtGraphicalEffects 1.12
20 import Ubuntu.Components 1.3
21 import Ubuntu.Gestures 0.1
22 import "../Components"
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 alias backgroundShadeOpacity: backgroundShade.opacity
33 property real panelHeight
34 property var infographicModel
35 property bool draggable: true
37 property bool showInfographic: false
38 property real infographicsLeftMargin: 0
39 property real infographicsTopMargin: 0
40 property real infographicsRightMargin: 0
41 property real infographicsBottomMargin: 0
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"
102 // Darkens wallpaper so that we can read text on it and see infographic
105 objectName: "backgroundShade"
115 leftMargin: root.infographicsLeftMargin
116 topMargin: root.infographicsTopMargin ? root.infographicsTopMargin : root.panelHeight
117 rightMargin: root.infographicsRightMargin
118 bottomMargin: root.infographicsBottomMargin
120 bottom: parent.bottom
127 id: infographicsLoader
128 objectName: "infographicsLoader"
129 active: root.showInfographic && infographicsArea.width > units.gu(32)
130 anchors.fill: infographicsArea
132 sourceComponent:Infographics {
134 objectName: "infographics"
135 model: root.infographicModel
136 clip: true // clip large data bubbles
142 objectName: "swipeHint"
143 property real baseOpacity: 0.5
145 anchors.horizontalCenter: parent.horizontalCenter
146 anchors.bottom: parent.bottom
147 anchors.bottomMargin: units.gu(5)
148 text: "《 " + (d.errorMessage ? d.errorMessage : i18n.tr("Unlock")) + " 》"
150 font.weight: Font.Light
152 readonly property var opacityAnimation: showLabelAnimation // for testing
154 SequentialAnimation on opacity {
155 id: showLabelAnimation
161 to: swipeHint.baseOpacity
162 duration: UbuntuAnimation.SleepyDuration
164 PauseAnimation { duration: UbuntuAnimation.BriskDuration }
166 from: swipeHint.baseOpacity
168 duration: UbuntuAnimation.SleepyDuration
178 WrongPasswordAnimation {
179 id: errorMessageAnimation
180 objectName: "errorMessageAnimation"
186 objectName: "coverPageDragHandle"
188 anchors.leftMargin: root.dragHandleLeftMargin
189 enabled: root.draggable
190 direction: Direction.Horizontal
195 showLabelAnimation.start();
202 anchors.left: parent.right
203 anchors.top: parent.top
204 anchors.bottom: parent.bottom
206 source: "../graphics/dropshadow_right.png"
211 anchors.right: parent.left
212 anchors.top: parent.top
213 anchors.bottom: parent.bottom
215 source: "../graphics/dropshadow_left.png"
221 property bool enabled: false
223 if (enabled === __enabled) {
229 value = Qt.binding(function() { return root.width; })
231 value = Qt.binding(function() { return -root.width; })
238 property bool __enabled: false
245 hideAnimation: SequentialAnimation {
247 objectName: "hideAnimation"
248 property var target // unused, here to silence Showable warning
254 PropertyAction { target: root; property: "visible"; value: false }
255 PropertyAction { target: positionLock; property: "enabled"; value: true }
258 showAnimation: SequentialAnimation {
260 objectName: "showAnimation"
261 property var target // unused, here to silence Showable warning
262 PropertyAction { target: root; property: "visible"; value: true }
263 PropertyAction { target: positionLock; property: "enabled"; value: false }
268 duration: UbuntuAnimation.FastDuration