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