2 * Copyright (C) 2013-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 Ubuntu.Components 1.3
19 import Ubuntu.Gestures 0.1
20 import "../Components"
25 property real dragHandleLeftMargin
26 property real launcherOffset
27 property alias background: greeterBackground.source
28 property alias hasCustomBackground: backgroundShade.visible
29 property real backgroundTopMargin
30 property var infographicModel
31 property bool draggable: true
33 property alias infographics: infographics
35 readonly property real showProgress: MathUtils.clamp((width - Math.abs(x + launcherOffset)) / width, 0, 1)
40 function hideRight() {
41 d.forceRightOnNextHideAnimation = true;
45 function showErrorMessage(msg) {
47 showLabelAnimation.start();
48 errorMessageAnimation.start();
53 property bool forceRightOnNextHideAnimation: false
54 property string errorMessage
57 prepareToHide: function () {
58 hideTranslation.from = root.x + translation.x
59 hideTranslation.to = root.x > 0 || d.forceRightOnNextHideAnimation ? root.width : -root.width;
60 d.forceRightOnNextHideAnimation = false;
63 // We don't directly bind "x" because that's owned by the DragHandle. So
64 // instead, we can get a little extra horizontal push by using transforms.
65 transform: Translate { id: translation; x: root.draggable ? launcherOffset : 0 }
67 // Eat events elsewhere on the coverpage, except mouse clicks which we pass
68 // up (they are used in the NarrowView to hide the cover page)
71 onClicked: root.clicked()
80 // In case background fails to load
88 objectName: "greeterBackground"
91 topMargin: root.backgroundTopMargin
95 // Darkens wallpaper so that we can read text on it and see infographic
98 objectName: "backgroundShade"
107 objectName: "infographics"
108 height: parent.height
109 model: root.infographicModel
110 clip: true // clip large data bubbles
113 verticalCenter: parent.verticalCenter
121 objectName: "swipeHint"
122 property real baseOpacity: 0.5
124 anchors.horizontalCenter: parent.horizontalCenter
125 anchors.bottom: parent.bottom
126 anchors.bottomMargin: units.gu(5)
127 text: "《 " + (d.errorMessage ? d.errorMessage : i18n.tr("Unlock")) + " 》"
129 font.weight: Font.Light
131 readonly property var opacityAnimation: showLabelAnimation // for testing
133 SequentialAnimation on opacity {
134 id: showLabelAnimation
140 to: swipeHint.baseOpacity
141 duration: UbuntuAnimation.SleepyDuration
143 PauseAnimation { duration: UbuntuAnimation.BriskDuration }
145 from: swipeHint.baseOpacity
147 duration: UbuntuAnimation.SleepyDuration
157 WrongPasswordAnimation {
158 id: errorMessageAnimation
159 objectName: "errorMessageAnimation"
165 objectName: "coverPageDragHandle"
167 anchors.leftMargin: root.dragHandleLeftMargin
168 enabled: root.draggable
169 direction: Direction.Horizontal
174 showLabelAnimation.start();
181 anchors.left: parent.right
182 anchors.top: parent.top
183 anchors.bottom: parent.bottom
185 source: "../graphics/dropshadow_right.png"
190 anchors.right: parent.left
191 anchors.top: parent.top
192 anchors.bottom: parent.bottom
194 source: "../graphics/dropshadow_left.png"
200 property bool enabled: false
202 if (enabled === __enabled) {
208 value = Qt.binding(function() { return root.width; })
210 value = Qt.binding(function() { return -root.width; })
217 property bool __enabled: false
224 hideAnimation: SequentialAnimation {
226 objectName: "hideAnimation"
227 property var target // unused, here to silence Showable warning
233 PropertyAction { target: root; property: "visible"; value: false }
234 PropertyAction { target: positionLock; property: "enabled"; value: true }
237 showAnimation: SequentialAnimation {
239 objectName: "showAnimation"
240 property var target // unused, here to silence Showable warning
241 PropertyAction { target: root; property: "visible"; value: true }
242 PropertyAction { target: positionLock; property: "enabled"; value: false }
247 duration: UbuntuAnimation.FastDuration