on a40c1fe help sign in
unity8/GreeterShell.qml
170 lines 4.9 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 }
54 }
55 }
57 Connections {
58 target: LightDM.Greeter
60 onShowPrompt: {
61 if (LightDM.Users.count == 1) {
62 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
63 if (text == "PIN") {
64 lockscreen.alphaNumeric = false
65 } else {
66 lockscreen.alphaNumeric = true
67 }
68 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
69 lockscreen.show();
70 }
71 }
72 }
74 Greeter {
75 id: greeter
77 available: true
78 hides: [launcher, panel.indicators]
79 shown: true
81 y: panel.panelHeight
82 width: parent.width
83 height: parent.height - panel.panelHeight
85 dragHandleWidth: shell.edgeSize
87 function login() {
88 enabled = false;
89 LightDM.Greeter.startSessionSync();
90 }
92 onUnlocked: login()
93 onShownChanged: {
94 if (shown) {
95 lockscreen.reset();
96 // If there is only one user, we start authenticating with that one here.
97 // If there are more users, the Greeter will handle that
98 if (LightDM.Users.count == 1) {
99 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
100 }
101 greeter.forceActiveFocus();
102 }
103 else if (promptless)
104 login();
105 }
106 onSelected: {
107 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
108 shell.background = bgPath ? bgPath : default_background
109 }
111 onLeftTeaserPressedChanged: {
112 if (leftTeaserPressed) {
113 launcher.tease();
114 }
115 }
116 }
118 InputFilterArea {
119 anchors.fill: parent
120 blockInput: true
121 }
123 Revealer {
124 id: greeterRevealer
125 objectName: "greeterRevealer"
127 property real animatedProgress: MathLocal.clamp(-dragPosition / closedValue, 0, 1)
128 target: greeter
129 width: greeter.width
130 height: greeter.height
131 handleSize: shell.edgeSize
132 orientation: Qt.Horizontal
133 enabled: !greeter.locked
134 }
136 Item {
137 id: overlay
139 anchors.fill: parent
141 Panel {
142 id: panel
143 anchors.fill: parent //because this draws indicator menus
144 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
145 indicators {
146 hides: [launcher]
147 }
148 fullscreenMode: false
149 searchVisible: false
150 }
152 Launcher {
153 id: launcher
155 anchors.top: parent.top
156 anchors.bottom: parent.bottom
157 width: parent.width
158 dragAreaWidth: shell.edgeSize
159 available: !greeter.locked
160 onLauncherApplicationSelected: {
161 shell.activateApplication(name)
162 }
163 onShownChanged: {
164 if (shown) {
165 panel.indicators.hide()
166 }
167 }
168 }
169 }