on 4a20ff2 help sign in
unity8/qml/Greeter/GreeterContent.qml
158 lines 4.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 AccountsService 0.1
19import Ubuntu.Components 0.1
20import LightDM 0.1 as LightDM
21import "../Components"
23Item {
24 id: root
25 anchors.fill: parent
27 property bool ready: background.source == "" || background.status == Image.Ready || background.status == Image.Error
29 signal selected(int uid)
30 signal unlocked(int uid)
32 function tryToUnlock() {
33 if (loginLoader.item) {
34 loginLoader.item.tryToUnlock()
35 }
36 }
38 function reset() {
39 if (loginLoader.item) {
40 loginLoader.item.reset()
41 }
42 }
44 Rectangle {
45 // In case background fails to load
46 id: backgroundBackup
47 anchors.fill: parent
48 color: "black"
49 }
51 CrossFadeImage {
52 id: background
53 objectName: "greeterBackground"
54 anchors {
55 fill: parent
56 topMargin: backgroundTopMargin
57 }
58 fillMode: Image.PreserveAspectCrop
59 // Limit how much memory we'll reserve for this image
60 sourceSize.height: height
61 sourceSize.width: width
62 source: greeter.background
63 }
65 Rectangle {
66 anchors.fill: parent
67 color: "black"
68 opacity: 0.4
69 }
71 Loader {
72 id: loginLoader
73 objectName: "loginLoader"
74 anchors {
75 left: parent.left
76 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
77 verticalCenter: parent.verticalCenter
78 }
79 width: units.gu(29)
80 height: parent.height
82 // TODO: Once we have a system API for determining which mode we are
83 // in, tablet/phone/desktop, that should be used instead of narrowMode.
84 source: greeter.narrowMode ? "" : "LoginList.qml"
86 onLoaded: {
87 item.currentIndex = greeterContentLoader.currentIndex;
88 }
90 Binding {
91 target: loginLoader.item
92 property: "model"
93 value: greeterContentLoader.model
94 }
96 Connections {
97 target: loginLoader.item
99 onSelected: {
100 root.selected(uid);
101 }
103 onUnlocked: {
104 root.unlocked(uid);
105 }
107 onCurrentIndexChanged: {
108 if (greeterContentLoader.currentIndex !== loginLoader.item.currentIndex) {
109 greeterContentLoader.currentIndex = loginLoader.item.currentIndex;
110 }
111 }
112 }
113 }
115 Infographics {
116 id: infographics
117 objectName: "infographics"
118 height: narrowMode ? parent.height : 0.75 * parent.height
119 model: greeterContentLoader.infographicModel
121 property string selectedUser
122 property string infographicUser: AccountsService.statsWelcomeScreen ? selectedUser : ""
123 onInfographicUserChanged: greeterContentLoader.infographicModel.username = infographicUser
125 Component.onCompleted: {
126 selectedUser = greeterContentLoader.model.data(greeterContentLoader.currentIndex, LightDM.UserRoles.NameRole)
127 greeterContentLoader.infographicModel.username = infographicUser
128 greeterContentLoader.infographicModel.readyForDataChange()
129 }
131 Connections {
132 target: root
133 onSelected: infographics.selectedUser = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
134 }
136 Connections {
137 target: i18n
138 onLanguageChanged: greeterContentLoader.infographicModel.readyForDataChange()
139 }
141 anchors {
142 verticalCenter: parent.verticalCenter
143 left: narrowMode ? root.left : loginLoader.right
144 right: root.right
145 }
146 }
148 Clock {
149 id: clock
150 visible: narrowMode
152 anchors {
153 top: parent.top
154 topMargin: units.gu(2)
155 horizontalCenter: parent.horizontalCenter
156 }
157 }