on 64d2900 help sign in
unity8/Greeter/GreeterContent.qml
136 lines 4.0 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 LightDM 0.1 as LightDM
20import "../Components"
22MouseArea {
23 id: root
24 anchors.fill: parent
26 property bool promptless: loginLoader.status == Loader.Ready && LightDM.Greeter.promptless
27 property bool ready: wallpaper.status == Image.Ready
28 property bool leftTeaserPressed: teasingMouseArea.pressed &&
29 teasingMouseArea.mouseX < teasingMouseArea.width / 2
30 property bool rightTeaserPressed: teasingMouseArea.pressed &&
31 teasingMouseArea.mouseX > teasingMouseArea.width / 2
33 signal selected(int uid)
34 signal unlocked(int uid)
36 CrossFadeImage {
37 id: wallpaper
39 source: shell.background
40 anchors.fill: parent
41 crossFade: false
42 fadeInFirst: false
43 }
45 Rectangle {
46 anchors.fill: parent
47 color: "black"
48 opacity: 0.4
49 }
51 Clock {
52 id: clock
53 visible: narrowMode
55 anchors {
56 top: parent.top
57 topMargin: units.gu(2)
58 horizontalCenter: parent.horizontalCenter
59 }
60 }
62 MouseArea {
63 id: teasingMouseArea
64 anchors.fill: parent
65 }
67 Loader {
68 id: loginLoader
69 objectName: "loginLoader"
70 anchors {
71 left: parent.left
72 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
73 verticalCenter: parent.verticalCenter
74 }
75 width: units.gu(29)
76 height: parent.height
78 // TODO: Once we have a system API for determining which mode we are
79 // in, tablet/phone/desktop, that should be used instead of narrowMode.
80 source: greeter.narrowMode ? "" : "LoginList.qml"
82 onLoaded: {
83 item.currentIndex = greeterContentLoader.currentIndex;
84 selected(item.currentIndex);
85 item.resetAuthentication();
86 }
88 Binding {
89 target: loginLoader.item
90 property: "model"
91 value: greeterContentLoader.model
92 }
94 Connections {
95 target: loginLoader.item
97 onSelected: {
98 root.selected(uid);
99 }
101 onUnlocked: {
102 root.unlocked(uid);
103 }
105 onCurrentIndexChanged: {
106 if (greeterContentLoader.currentIndex !== loginLoader.item.currentIndex) {
107 greeterContentLoader.currentIndex = loginLoader.item.currentIndex;
108 }
109 }
110 }
111 }
113 Infographics {
114 id: infographics
115 height: narrowMode ? parent.height : 0.75 * parent.height
116 model: greeterContentLoader.infographicModel
118 Component.onCompleted: infographics.updateUsername(greeterContentLoader.currentIndex)
120 Connections {
121 target: root
122 onSelected: infographics.updateUsername(uid)
123 }
125 function updateUsername(uid) {
126 greeterContentLoader.infographicModel.username = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
127 greeterContentLoader.infographicModel.readyForDataChangeSlot();
128 }
130 anchors {
131 verticalCenter: parent.verticalCenter
132 left: narrowMode ? root.left : loginLoader.right
133 right: root.right
134 }
135 }