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