on 7e80e75 help sign in
unity8/Greeter/Greeter.qml
119 lines 3.6 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Ubuntu.Gestures 0.1
20import LightDM 0.1 as LightDM
21import "../Components"
22import "../Components/Math.js" as MathLocal
24Showable {
25 id: greeter
26 enabled: shown
27 created: greeterContentLoader.status == Loader.Ready && greeterContentLoader.item.ready
29 // 1 when fully shown and 0 when fully hidden
30 property real showProgress: MathLocal.clamp((width + x) / width, 0, 1)
32 showAnimation: StandardAnimation { property: "x"; to: 0 }
33 hideAnimation: StandardAnimation { property: "x"; to: -width }
35 property alias dragHandleWidth: dragHandle.width
36 property alias model: greeterContentLoader.model
37 property bool locked: shown && !LightDM.Greeter.promptless
39 readonly property bool narrowMode: !multiUser && width <= units.gu(60)
40 readonly property bool multiUser: LightDM.Users.count > 1
42 readonly property bool leftTeaserPressed: greeterContentLoader.status == Loader.Ready &&
43 greeterContentLoader.item.leftTeaserPressed
44 readonly property bool rightTeaserPressed: greeterContentLoader.status == Loader.Ready &&
45 greeterContentLoader.item.rightTeaserPressed
47 signal selected(int uid)
48 signal unlocked(int uid)
50 onRightTeaserPressedChanged: {
51 if (rightTeaserPressed && !locked) {
52 teasingTimer.start();
53 }
54 }
56 Loader {
57 id: greeterContentLoader
58 objectName: "greeterContentLoader"
59 anchors.fill: parent
60 property var model: LightDM.Users
61 property int currentIndex: 0
62 property var infographicModel: LightDM.Infographic
64 source: required ? "GreeterContent.qml" : ""
67 Connections {
68 target: greeterContentLoader.item
70 onSelected: greeter.selected(uid);
71 onUnlocked: greeter.unlocked(uid);
72 }
73 }
75 Timer {
76 id: teasingTimer
77 interval: 200
78 }
80 states: [
81 State {
82 name: "teasing"
83 when: teasingTimer.running
84 PropertyChanges {
85 target: greeter
86 x: -units.gu(2)
87 }
88 }
89 ]
90 transitions: [
91 Transition {
92 from: "*"
93 to: "*"
94 NumberAnimation {
95 target: greeter
96 property: "x"
97 duration: 300
98 easing.type: Easing.OutCubic
99 }
100 }
101 ]
103 DragHandle {
104 id: dragHandle
106 anchors.top: parent.top
107 anchors.bottom: parent.bottom
108 anchors.right: parent.right
110 // no need for requiring a directional drag since we are covering the screen
111 // anyway (i.e., no change user could be trying to interact with some other
112 // UI element)
113 distanceThreshold: 0
115 enabled: greeter.narrowMode || !greeter.locked
117 direction: Direction.Leftwards
118 }