on 29019df help sign in
unity8/qml/Greeter/GreeterContent.qml
156 lines 4.8 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 Rectangle {
33 // In case background fails to load
34 id: backgroundBackup
35 anchors.fill: parent
36 color: "black"
37 }
39 property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : greeter.defaultBackground
40 onBackgroundValueChanged: background.source = backgroundValue
42 CrossFadeImage {
43 id: background
44 objectName: "greeterBackground"
45 anchors {
46 fill: parent
47 topMargin: backgroundTopMargin
48 }
49 fillMode: Image.PreserveAspectCrop
50 }
52 // See Shell.qml's backgroundSettings treatment for why we need a separate
53 // Image, but it boils down to avoiding binding loop detection.
54 Image {
55 source: background.source
56 height: 0
57 width: 0
58 sourceSize.height: 0
59 sourceSize.width: 0
60 onStatusChanged: {
61 if (status == Image.Error && source != greeter.defaultBackground) {
62 background.source = greeter.defaultBackground
63 }
64 }
65 }
67 Rectangle {
68 anchors.fill: parent
69 color: "black"
70 opacity: 0.4
71 }
73 Loader {
74 id: loginLoader
75 objectName: "loginLoader"
76 anchors {
77 left: parent.left
78 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
79 verticalCenter: parent.verticalCenter
80 }
81 width: units.gu(29)
82 height: parent.height
84 // TODO: Once we have a system API for determining which mode we are
85 // in, tablet/phone/desktop, that should be used instead of narrowMode.
86 source: greeter.narrowMode ? "" : "LoginList.qml"
88 onLoaded: {
89 item.currentIndex = greeterContentLoader.currentIndex;
90 item.resetAuthentication();
91 }
93 Binding {
94 target: loginLoader.item
95 property: "model"
96 value: greeterContentLoader.model
97 }
99 Connections {
100 target: loginLoader.item
102 onSelected: {
103 root.selected(uid);
104 }
106 onUnlocked: {
107 root.unlocked(uid);
108 }
110 onCurrentIndexChanged: {
111 if (greeterContentLoader.currentIndex !== loginLoader.item.currentIndex) {
112 greeterContentLoader.currentIndex = loginLoader.item.currentIndex;
113 }
114 }
115 }
116 }
118 Infographics {
119 id: infographics
120 objectName: "infographics"
121 height: narrowMode ? parent.height : 0.75 * parent.height
122 model: greeterContentLoader.infographicModel
124 property string selectedUser
125 property string infographicUser: AccountsService.statsWelcomeScreen ? selectedUser : ""
126 onInfographicUserChanged: greeterContentLoader.infographicModel.username = infographicUser
128 Component.onCompleted: {
129 selectedUser = greeterContentLoader.model.data(greeterContentLoader.currentIndex, LightDM.UserRoles.NameRole)
130 greeterContentLoader.infographicModel.username = infographicUser
131 greeterContentLoader.infographicModel.readyForDataChange()
132 }
134 Connections {
135 target: root
136 onSelected: infographics.selectedUser = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
137 }
139 anchors {
140 verticalCenter: parent.verticalCenter
141 left: narrowMode ? root.left : loginLoader.right
142 right: root.right
143 }
144 }
146 Clock {
147 id: clock
148 visible: narrowMode
150 anchors {
151 top: parent.top
152 topMargin: units.gu(2)
153 horizontalCenter: parent.horizontalCenter
154 }
155 }