2 * Copyright (C) 2013 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 0.1
19 import Ubuntu.Gestures 0.1
20 import LightDM 0.1 as LightDM
21 import "../Components"
26 created: greeterContentLoader.status == Loader.Ready && greeterContentLoader.item.ready
28 property real dragHandleLeftMargin: 0
29 property alias dragging: dragHandle.dragging
31 property url background
33 // so that it can be replaced in tests with a mock object
34 property var inputMethod: Qt.inputMethod
36 prepareToHide: function () {
37 hideTranslation.to = greeter.x > 0 || d.forceRightOnNextHideAnimation ? greeter.width : -greeter.width;
38 d.forceRightOnNextHideAnimation = false;
43 property bool forceRightOnNextHideAnimation: false
46 property bool loadContent: required
48 // 1 when fully shown and 0 when fully hidden
49 property real showProgress: visible ? MathUtils.clamp((width - Math.abs(x)) / width, 0, 1) : 0
51 property alias model: greeterContentLoader.model
52 property bool locked: true
54 readonly property bool narrowMode: !multiUser && height > width
55 readonly property bool multiUser: LightDM.Users.count > 1
57 readonly property int currentIndex: greeterContentLoader.currentIndex
59 signal selected(int uid)
60 signal unlocked(int uid)
63 function hideRight() {
64 d.forceRightOnNextHideAnimation = true;
68 function tryToUnlock() {
70 greeterContentLoader.item.tryToUnlock()
76 greeterContentLoader.item.reset()
81 // Nothing should leak to items behind the greeter
82 MouseArea { anchors.fill: parent }
85 id: greeterContentLoader
86 objectName: "greeterContentLoader"
88 property var model: LightDM.Users
89 property int currentIndex: 0
90 property var infographicModel: LightDM.Infographic
91 readonly property int backgroundTopMargin: -greeter.y
93 source: loadContent ? "GreeterContent.qml" : ""
96 selected(currentIndex);
100 target: greeterContentLoader.item
103 greeter.selected(uid);
104 greeterContentLoader.currentIndex = uid;
106 onUnlocked: greeter.unlocked(uid);
109 target: greeterContentLoader.item
110 property: "inputMethod"
111 value: greeter.inputMethod
118 anchors.leftMargin: greeter.dragHandleLeftMargin
119 enabled: (greeter.narrowMode || !greeter.locked) && greeter.enabled && greeter.shown
120 direction: Direction.Horizontal
124 showLabelAnimation.start();
129 showLabelAnimation.start();
136 property real baseOpacity: 0.5
138 anchors.horizontalCenter: parent.horizontalCenter
139 anchors.bottom: parent.bottom
140 anchors.bottomMargin: units.gu(5)
141 text: "《 " + i18n.tr("Unlock") + " 》"
143 font.weight: Font.Light
145 SequentialAnimation on opacity {
146 id: showLabelAnimation
152 to: swipeHint.baseOpacity
153 duration: UbuntuAnimation.SleepyDuration
155 PauseAnimation { duration: UbuntuAnimation.BriskDuration }
157 from: swipeHint.baseOpacity
159 duration: UbuntuAnimation.SleepyDuration
166 anchors.left: parent.right
167 anchors.top: parent.top
168 anchors.bottom: parent.bottom
170 source: "../graphics/dropshadow_right.png"
175 anchors.right: parent.left
176 anchors.top: parent.top
177 anchors.bottom: parent.bottom
179 source: "../graphics/dropshadow_left.png"
185 property bool enabled: false
187 if (enabled === __enabled) {
193 value = Qt.binding(function() { return greeter.width; })
195 value = Qt.binding(function() { return -greeter.width; })
202 property bool __enabled: false
209 hideAnimation: SequentialAnimation {
211 objectName: "hideAnimation"
217 PropertyAction { target: greeter; property: "visible"; value: false }
218 PropertyAction { target: positionLock; property: "enabled"; value: true }
221 showAnimation: SequentialAnimation {
223 objectName: "showAnimation"
224 PropertyAction { target: greeter; property: "visible"; value: true }
225 PropertyAction { target: positionLock; property: "enabled"; value: false }
230 duration: UbuntuAnimation.FastDuration