on 31777a2 help sign in
unity8/Greeter/GreeterContent.qml
131 lines 3.6 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 alias leftTeaserPressed: leftTeaser.pressed
30 signal selected(int uid)
31 signal unlocked(int uid)
33 CrossFadeImage {
34 id: wallpaper
36 source: shell.background
37 anchors.fill: parent
38 crossFade: false
39 fadeInFirst: false
40 }
42 Rectangle {
43 anchors.fill: parent
44 color: "black"
45 opacity: 0.4
46 }
48 Clock {
49 id: clock
50 visible: narrowMode
52 anchors {
53 top: parent.top
54 topMargin: units.gu(2)
55 horizontalCenter: parent.horizontalCenter
56 }
57 }
59 MouseArea {
60 id: leftTeaser
61 anchors.fill: parent
62 anchors.rightMargin: parent.width / 2
63 }
65 Loader {
66 id: loginLoader
67 objectName: "loginLoader"
68 anchors {
69 left: parent.left
70 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
71 verticalCenter: parent.verticalCenter
72 }
73 width: units.gu(29)
74 height: parent.height
76 // TODO: Once we have a system API for determining which mode we are
77 // in, tablet/phone/desktop, that should be used instead of narrowMode.
78 source: greeter.narrowMode ? "" : "LoginList.qml"
80 onLoaded: {
81 item.currentIndex = greeterContentLoader.currentIndex
82 }
84 Binding {
85 target: loginLoader.item
86 property: "model"
87 value: greeterContentLoader.model
88 }
90 Connections {
91 target: loginLoader.item
93 onSelected: {
94 root.selected(uid);
95 }
97 onUnlocked: {
98 root.unlocked(uid);
99 }
101 onCurrentIndexChanged: {
102 if (greeterContentLoader.currentIndex !== loginLoader.item.currentIndex) {
103 greeterContentLoader.currentIndex = loginLoader.item.currentIndex;
104 }
105 }
106 }
107 }
109 Infographics {
110 id: infographics
111 height: narrowMode ? parent.height : 0.75 * parent.height
112 model: greeterContentLoader.infographicModel
114 Component.onCompleted: infographics.updateUsername(greeterContentLoader.currentIndex)
116 Connections {
117 target: root
118 onSelected: infographics.updateUsername(uid)
119 }
121 function updateUsername(uid) {
122 greeterContentLoader.infographicModel.username = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
123 }
125 anchors {
126 verticalCenter: parent.verticalCenter
127 left: narrowMode ? root.left : loginLoader.right
128 right: root.right
129 }
130 }