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 real backgroundTopMargin
29 property var infographicModel
30 property bool draggable: true
32 property alias infographics: infographics
34 readonly property real showProgress: MathUtils.clamp((width - Math.abs(x)) / width, 0, 1)
39 function hideRight() {
40 d.forceRightOnNextHideAnimation = true;
46 property bool forceRightOnNextHideAnimation: false
49 prepareToHide: function () {
50 hideTranslation.from = root.x + translation.x
51 hideTranslation.to = root.x > 0 || d.forceRightOnNextHideAnimation ? root.width : -root.width;
52 d.forceRightOnNextHideAnimation = false;
55 // We don't directly bind "x" because that's owned by the DragHandle. So
56 // instead, we can get a little extra horizontal push by using transforms.
57 transform: Translate { id: translation; x: root.draggable ? launcherOffset : 0 }
59 // Eat events elsewhere on the coverpage, except mouse clicks which we pass
60 // up (they are used in the NarrowView to hide the cover page)
63 onClicked: root.clicked()
72 // In case background fails to load
80 objectName: "greeterBackground"
83 topMargin: root.backgroundTopMargin
85 fillMode: Image.PreserveAspectCrop
86 // Limit how much memory we'll reserve for this image
87 sourceSize.height: height
88 sourceSize.width: width
99 objectName: "infographics"
100 height: parent.height
101 model: root.infographicModel
102 clip: true // clip large data bubbles
105 verticalCenter: parent.verticalCenter
113 property real baseOpacity: 0.5
115 anchors.horizontalCenter: parent.horizontalCenter
116 anchors.bottom: parent.bottom
117 anchors.bottomMargin: units.gu(5)
118 text: "《 " + i18n.tr("Unlock") + " 》"
120 font.weight: Font.Light
122 SequentialAnimation on opacity {
123 id: showLabelAnimation
129 to: swipeHint.baseOpacity
130 duration: UbuntuAnimation.SleepyDuration
132 PauseAnimation { duration: UbuntuAnimation.BriskDuration }
134 from: swipeHint.baseOpacity
136 duration: UbuntuAnimation.SleepyDuration
143 objectName: "coverPageDragHandle"
145 anchors.leftMargin: root.dragHandleLeftMargin
146 enabled: root.draggable
147 direction: Direction.Horizontal
152 showLabelAnimation.start();
159 anchors.left: parent.right
160 anchors.top: parent.top
161 anchors.bottom: parent.bottom
163 source: "../graphics/dropshadow_right.png"
168 anchors.right: parent.left
169 anchors.top: parent.top
170 anchors.bottom: parent.bottom
172 source: "../graphics/dropshadow_left.png"
178 property bool enabled: false
180 if (enabled === __enabled) {
186 value = Qt.binding(function() { return root.width; })
188 value = Qt.binding(function() { return -root.width; })
195 property bool __enabled: false
202 hideAnimation: SequentialAnimation {
204 objectName: "hideAnimation"
205 property var target // unused, here to silence Showable warning
211 PropertyAction { target: root; property: "visible"; value: false }
212 PropertyAction { target: positionLock; property: "enabled"; value: true }
215 showAnimation: SequentialAnimation {
217 objectName: "showAnimation"
218 property var target // unused, here to silence Showable warning
219 PropertyAction { target: root; property: "visible"; value: true }
220 PropertyAction { target: positionLock; property: "enabled"; value: false }
225 duration: UbuntuAnimation.FastDuration