on 78ccb79 help sign in
unity8/GreeterShell.qml
181 lines 5.2 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.Application 0.1
19import LightDM 0.1 as LightDM
20import "Greeter"
21import "Launcher"
22import "Panel"
23import "Components"
24import "Components/Math.js" as MathLocal
26BasicShell {
27 id: shell
29 function activateApplication(desktopFile, argument) {
30 greeter.login()
31 // TODO: support opening the app once inside user's session
32 }
34 Lockscreen {
35 id: lockscreen
36 hides: [launcher, panel.indicators]
37 shown: false
38 enabled: true
39 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
40 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
41 y: panel.panelHeight
42 x: required ? 0 : - width
43 width: parent.width
44 height: parent.height - panel.panelHeight
45 background: shell.background
47 onUnlocked: lockscreen.hide()
48 onCancel: greeter.show()
50 Component.onCompleted: {
51 if (LightDM.Users.count == 1) {
52 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
53 greeter.selected(0)
54 }
55 }
56 }
58 Connections {
59 target: LightDM.Greeter
61 onShowPrompt: {
62 if (LightDM.Users.count == 1) {
63 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
64 if (text == "PIN") {
65 lockscreen.alphaNumeric = false
66 } else {
67 lockscreen.alphaNumeric = true
68 }
69 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
70 lockscreen.show();
71 }
72 }
73 }
75 Greeter {
76 id: greeter
77 objectName: "greeter"
79 available: true
80 hides: [launcher, panel.indicators]
81 shown: true
83 y: panel.panelHeight
84 width: parent.width
85 height: parent.height - panel.panelHeight
87 dragHandleWidth: shell.edgeSize
89 function login() {
90 enabled = false;
91 LightDM.Greeter.startSessionSync();
92 }
94 onShownChanged: {
95 if (shown) {
96 lockscreen.reset();
97 // If there is only one user, we start authenticating with that one here.
98 // If there are more users, the Greeter will handle that
99 if (LightDM.Users.count == 1) {
100 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
101 greeter.selected(0);
102 }
103 greeter.forceActiveFocus();
104 }
105 else if (LightDM.Greeter.promptless)
106 login();
107 }
109 onUnlocked: login()
110 onSelected: {
111 // Update launcher items for new user
112 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
113 LauncherModel.setUser(user);
114 }
116 onLeftTeaserPressedChanged: {
117 if (leftTeaserPressed) {
118 launcher.tease();
119 }
120 }
121 }
123 InputFilterArea {
124 anchors.fill: parent
125 blockInput: true
126 }
128 Revealer {
129 id: greeterRevealer
130 objectName: "greeterRevealer"
132 property real animatedProgress: MathLocal.clamp(-dragPosition / closedValue, 0, 1)
133 target: greeter
134 width: greeter.width
135 height: greeter.height
136 handleSize: shell.edgeSize
137 orientation: Qt.Horizontal
138 enabled: !greeter.locked
139 }
141 Item {
142 id: overlay
144 anchors.fill: parent
146 Panel {
147 id: panel
148 anchors.fill: parent //because this draws indicator menus
149 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
150 indicators {
151 hides: [launcher]
152 available: !edgeDemo.active
153 }
154 fullscreenMode: false
155 searchVisible: false
156 }
158 Launcher {
159 id: launcher
161 anchors.top: parent.top
162 anchors.bottom: parent.bottom
163 width: parent.width
164 dragAreaWidth: shell.edgeSize
165 available: greeter.narrowMode && !edgeDemo.active
166 onLauncherApplicationSelected: {
167 shell.activateApplication(name)
168 }
169 onShownChanged: {
170 if (shown) {
171 panel.indicators.hide()
172 }
173 }
174 }
175 }
177 GreeterEdgeDemo {
178 id: edgeDemo
179 greeter: greeter
180 }