on bf461a2 help sign in
unity8/Greeter/Greeter.qml
125 lines 3.8 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 property url defaultBackground
31 // 1 when fully shown and 0 when fully hidden
32 property real showProgress: MathLocal.clamp((width + x) / width, 0, 1)
34 showAnimation: StandardAnimation { property: "x"; to: 0 }
35 hideAnimation: StandardAnimation { property: "x"; to: -width }
37 property alias dragHandleWidth: dragHandle.width
38 property alias model: greeterContentLoader.model
39 property bool locked: shown && !LightDM.Greeter.promptless
41 readonly property bool narrowMode: !multiUser && width <= units.gu(60)
42 readonly property bool multiUser: LightDM.Users.count > 1
44 readonly property bool leftTeaserPressed: greeterContentLoader.status == Loader.Ready &&
45 greeterContentLoader.item.leftTeaserPressed
46 readonly property bool rightTeaserPressed: greeterContentLoader.status == Loader.Ready &&
47 greeterContentLoader.item.rightTeaserPressed
49 readonly property int currentIndex: greeterContentLoader.currentIndex
51 signal selected(int uid)
52 signal unlocked(int uid)
54 onRightTeaserPressedChanged: {
55 if (rightTeaserPressed && !locked) {
56 teasingTimer.start();
57 }
58 }
60 Loader {
61 id: greeterContentLoader
62 objectName: "greeterContentLoader"
63 anchors.fill: parent
64 property var model: LightDM.Users
65 property int currentIndex: 0
66 property var infographicModel: LightDM.Infographic
68 source: required ? "GreeterContent.qml" : ""
70 Connections {
71 target: greeterContentLoader.item
73 onSelected: {
74 greeter.selected(uid);
75 greeterContentLoader.currentIndex = uid;
76 }
77 onUnlocked: greeter.unlocked(uid);
78 }
79 }
81 Timer {
82 id: teasingTimer
83 interval: 200
84 }
86 states: [
87 State {
88 name: "teasing"
89 when: teasingTimer.running
90 PropertyChanges {
91 target: greeter
92 x: -units.gu(2)
93 }
94 }
95 ]
96 transitions: [
97 Transition {
98 from: "*"
99 to: "*"
100 NumberAnimation {
101 target: greeter
102 property: "x"
103 duration: 300
104 easing.type: Easing.OutCubic
105 }
106 }
107 ]
109 DragHandle {
110 id: dragHandle
112 anchors.top: parent.top
113 anchors.bottom: parent.bottom
114 anchors.right: parent.right
116 // no need for requiring a directional drag since we are covering the screen
117 // anyway (i.e., no change user could be trying to interact with some other
118 // UI element)
119 distanceThreshold: 0
121 enabled: greeter.narrowMode || !greeter.locked
123 direction: Direction.Leftwards
124 }