on xenial help sign in
Add gui files
commit19316e129c4b452f5e49c8fb448cd4c567486b23 authorJosh Arenson <joshua.arenson@canonical.com> dateThu 19 Nov 2015, 13:47 (11 years ago) parent9ef0600
14 files changed+264−46
qml/Greeter/FullLightDMImpl.qml+2 qml/Greeter/Greeter.qml+11−1 qml/Greeter/IntegratedLightDMImpl.qml+2−1 qml/Greeter/LightDMService.qml+2 qml/Greeter/LoginAreaContainer.qml+11 qml/Greeter/LoginList.qml+41−8 qml/Greeter/NarrowView.qml+1 qml/Greeter/SessionsList.qml+68 qml/Greeter/WideView.qml+126−36 qml/Greeter/graphics/session_icons/gnome_badge.png qml/Greeter/graphics/session_icons/plasma_badge.png qml/Greeter/graphics/session_icons/recovery_console_badge.png qml/Greeter/graphics/session_icons/ubuntu_badge.png qml/Greeter/graphics/session_icons/unknown_badge.png
qml/Greeter/FullLightDMImpl.qml+2
@@ -22,6 +22,8 @@ Item{
2222
2323 property var greeter: LightDM.Greeter
2424 property var infographic: LightDM.Infographic
25+ property var sessions: LightDM.Sessions
26+ property var sessionRoles: LightDM.SessionRoles
2527 property var users: LightDM.Users
2628 property var userRoles: LightDM.UserRoles
2729
qml/Greeter/Greeter.qml+11−1
@@ -55,6 +55,16 @@ Showable {
5555
5656 readonly property bool animating: loader.item ? loader.item.animating : false
5757
58+ property string sessionToStart: {
59+ if (loader.item.sessionToStart) {
60+ return loader.item.sessionToStart
61+ } else if (LightDMService.greeter.defaultSession) {
62+ return LightDMService.greeter.defaultSession
63+ } else {
64+ return "ubuntu"
65+ }
66+ }
67+
5868 signal tease()
5969 signal sessionStarted()
6070 signal emergencyCall()
@@ -142,7 +152,7 @@ Showable {
142152
143153 function login() {
144154 enabled = false;
145− if (LightDMService.greeter.startSessionSync()) {
155+ if (LightDMService.greeter.startSessionSync(root.sessionToStart.toLowerCase())) {
146156 sessionStarted();
147157 if (loader.item) {
148158 loader.item.notifyAuthenticationSucceeded();
qml/Greeter/IntegratedLightDMImpl.qml+2−1
@@ -22,7 +22,8 @@ Item{
2222
2323 property var greeter: LightDM.Greeter
2424 property var infographic: LightDM.Infographic
25+ property var sessions: LightDM.Sessions
26+ property var sessionRoles: LightDM.SessionRoles
2527 property var users: LightDM.Users
2628 property var userRoles: LightDM.UserRoles
27−
2829}
qml/Greeter/LightDMService.qml+2
@@ -27,6 +27,8 @@ Loader {
2727
2828 property var greeter: d.valid ? loader.item.greeter : null
2929 property var infographic: d.valid ? loader.item.infographic : null
30+ property var sessions: d.valid ? loader.item.sessions : null
31+ property var sessionRoles: d.valid ? loader.item.sessionRoles : null
3032 property var users: d.valid ? loader.item.users : null
3133 property var userRoles: d.valid ? loader.item.userRoles : null
3234
qml/Greeter/LoginAreaContainer.qmlnew file+11
@@ -0,0 +1,11 @@
1+import QtQuick 2.4
2+import "." 0.1
3+
4+Rectangle {
5+ height: units.gu(10)
6+ color: Qt.rgba(0.1, 0.1, 0.1, 0.4)
7+ border.color: Qt.rgba(0.4, 0.4, 0.4, 0.4)
8+ border.width: units.dp(1)
9+ radius: units.gu(1.5)
10+ antialiasing: true
11+}
qml/Greeter/LoginList.qml+41−8
@@ -17,11 +17,13 @@
1717import QtQuick 2.4
1818import Ubuntu.Components 1.3
1919import "../Components"
20+import "." 0.1
2021
2122Item {
2223 id: root
2324
2425 property alias model: userList.model
26+ property url sessionIcon
2527 property int currentIndex
2628 property bool locked
2729
@@ -29,11 +31,18 @@ Item {
2931 readonly property int cellHeight: units.gu(5)
3032 readonly property int highlightedHeight: units.gu(10)
3133 readonly property int moveDuration: 200
34+ property string selectedSession
35+ property string currentSession: selectedSession ?
36+ selectedSession : userList.currentItem.userSession
3237 readonly property string currentUser: userList.currentItem.username
3338 property bool wasPrompted: false
3439
35− signal selected(int index)
3640 signal responded(string response)
41+ signal selected(int index)
42+ signal sessionChooserButtonClicked()
43+ signal loginListSessionChanged(string session)
44+
45+ onCurrentSessionChanged: loginListSessionChanged(currentSession)
3746
3847 function tryToUnlock() {
3948 if (wasPrompted) {
@@ -85,19 +94,42 @@ Item {
8594 userList.currentIndex = currentIndex;
8695 }
8796
88− Rectangle {
97+ LoginAreaContainer {
8998 id: highlightItem
9099 anchors {
91100 left: parent.left
92101 right: parent.right
93102 verticalCenter: parent.verticalCenter
94103 }
95− height: root.highlightedHeight
96− color: Qt.rgba(0.1, 0.1, 0.1, 0.4)
97− border.color: Qt.rgba(0.4, 0.4, 0.4, 0.4)
98− border.width: units.dp(1)
99− radius: units.gu(1.5)
100− antialiasing: true
104+
105+ z: sessionChooser.visible ? userList.z + 1 : z
106+
107+ // Use an AbstractButton due to icon limitations with Button
108+ AbstractButton {
109+ id: sessionChooser
110+
111+ visible: LightDMService.sessions.count > 1
112+
113+ height: units.gu(2.5)
114+ width: units.gu(2.5)
115+
116+ anchors {
117+ right: parent.right
118+ rightMargin: units.gu(1)
119+
120+ top: parent.top
121+ topMargin: units.gu(1)
122+ }
123+
124+ Image {
125+ anchors.fill: parent
126+ source: LightDMService.sessions.iconUrl(root.currentSession)
127+ }
128+
129+ onClicked: {
130+ sessionChooserButtonClicked();
131+ }
132+ }
101133 }
102134
103135 ListView {
@@ -130,6 +162,7 @@ Item {
130162
131163 readonly property bool belowHighlight: (userList.currentIndex < 0 && index > 0) || (userList.currentIndex >= 0 && index > userList.currentIndex)
132164 readonly property int belowOffset: root.highlightedHeight - root.cellHeight
165+ readonly property string userSession: session
133166 readonly property string username: name
134167
135168 opacity: {
qml/Greeter/NarrowView.qml+1
@@ -31,6 +31,7 @@ FocusScope {
3131 property bool alphanumeric
3232 property var userModel // unused
3333 property alias infographicModel: coverPage.infographicModel
34+ property string sessionToStart
3435 readonly property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown
3536 readonly property bool required: coverPage.required || lockscreen.required
3637 readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
qml/Greeter/SessionsList.qmlnew file+68
@@ -0,0 +1,68 @@
1+/*
2+ * Copyright (C) 2015 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+ */
16+
17+import QtQuick 2.4
18+import Ubuntu.Components 1.3
19+import Ubuntu.Components.ListItems 1.3
20+import "." 0.1
21+
22+Item {
23+ id: root
24+
25+ property string initiallySelectedSession
26+ property alias selectedIndex: sessionsList.selectedIndex
27+ signal sessionSelected(string sessionName)
28+
29+ LoginAreaContainer {
30+ height: sessionsList.itemHeight * sessionsList.model.count
31+
32+ anchors {
33+ left: parent.left
34+ right: parent.right
35+ verticalCenter: parent.verticalCenter
36+ }
37+
38+ ItemSelector {
39+ id: sessionsList
40+ property color originalBackground
41+ anchors.centerIn: parent
42+ width: parent.width - units.gu(1)
43+ expanded:true
44+ style: Item{}
45+
46+ model: LightDMService.sessions
47+ delegate: OptionSelectorDelegate {
48+ iconSource: icon_url
49+ text: display
50+ selected: display.toLowerCase() === initiallySelectedSession.toLowerCase()
51+ }
52+
53+ Component.onCompleted: {
54+ // Disbale the highlighting since it leaks outside of rounded corners
55+ originalBackground = theme.palette.selected.background
56+ theme.palette.selected.background = "transparent"
57+ }
58+ Component.onDestruction: {
59+ theme.palette.selected.background = originalBackground
60+ }
61+
62+ onDelegateClicked: {
63+ sessionSelected(sessionsList.model.data(index,
64+ LightDMService.sessionRoles.DisplayRole));
65+ }
66+ }
67+ }
68+}
qml/Greeter/WideView.qml+126−36
@@ -16,23 +16,27 @@
1616
1717import QtQuick 2.4
1818import Ubuntu.Components 1.3
19+import "." 0.1
1920
2021FocusScope {
2122 id: root
2223
24+ property alias background: coverPage.background
25+ property alias backgroundTopMargin: coverPage.backgroundTopMargin
2326 property alias dragHandleLeftMargin: coverPage.dragHandleLeftMargin
27+ property alias infographicModel: coverPage.infographicModel
2428 property alias launcherOffset: coverPage.launcherOffset
25− property alias currentIndex: loginList.currentIndex
29+ property alias loginListShown: loginAreaLoader.loginListShown
30+ property int currentIndex // Set from outside
2631 property int delayMinutes // TODO
27− property alias backgroundTopMargin: coverPage.backgroundTopMargin
28− property alias background: coverPage.background
29− property bool locked
3032 property bool alphanumeric // unused
31− property alias userModel: loginList.model
32− property alias infographicModel: coverPage.infographicModel
33+ property bool locked
34+ property alias sessionToStart: loginAreaLoader.currentSession
35+ property var userModel // Set from outside
36+
37+ readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
3338 readonly property bool fullyShown: coverPage.showProgress === 1
3439 readonly property bool required: coverPage.required
35− readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
3640
3741 // so that it can be replaced in tests with a mock object
3842 property var inputMethod: Qt.inputMethod
@@ -42,38 +46,39 @@ FocusScope {
4246 signal tease()
4347 signal emergencyCall() // unused
4448
45− function showMessage(html) {
46− loginList.showMessage(html);
47− }
48−
49− function showPrompt(text, isSecret, isDefaultPrompt) {
50− loginList.showPrompt(text, isSecret, isDefaultPrompt);
49+ /***** Functions that depend on LoginList being loaded *****/
50+ // A decorator to only call LoginList functions when its shown
51+ function ifLoginlistShownThen(f) {
52+ return function() {
53+ if (loginListShown) f.apply(this, arguments);
54+ }
5155 }
5256
53− function showLastChance() {
54− // TODO
57+ readonly property var notifyAuthenticationFailed: ifLoginlistShownThen(doNotifyAuthenticationFailed);
58+ function doNotifyAuthenticationFailed() {
59+ loginAreaLoader.item.showError();
5560 }
5661
57− function hide() {
58− coverPage.hide();
62+ readonly property var reset: ifLoginlistShownThen(doReset);
63+ function doReset() {
64+ loginAreaLoader.item.reset();
5965 }
6066
61− function notifyAuthenticationSucceeded() {
62− // Nothing needed
67+ readonly property var showMessage: ifLoginlistShownThen(doShowMessage);
68+ function doShowMessage(html) {
69+ loginAreaLoader.item.showMessage(html);
6370 }
6471
65− function notifyAuthenticationFailed() {
66− loginList.showError();
72+ readonly property var showPrompt: ifLoginlistShownThen(doShowPrompt);
73+ function doShowPrompt(text, isSecret, isDefaultPrompt) {
74+ loginAreaLoader.item.showPrompt(text, isSecret, isDefaultPrompt);
6775 }
6876
69− function reset() {
70− loginList.reset();
71− }
72−
73− function tryToUnlock(toTheRight) {
77+ readonly property var tryToUnlock: ifLoginlistShownThen(doTryToUnlock);
78+ function doTryToUnlock(toTheRight) {
7479 if (root.locked) {
7580 coverPage.show();
76− loginList.tryToUnlock();
81+ loginAreaLoader.item.tryToUnlock();
7782 return false;
7883 } else {
7984 var coverChanged = coverPage.shown;
@@ -86,6 +91,19 @@ FocusScope {
8691 }
8792 }
8893
94+ /***** Functions that are agnostic of what object is loaded *****/
95+ function hide() {
96+ coverPage.hide();
97+ }
98+
99+ function notifyAuthenticationSucceeded() {
100+ // Nothing needed
101+ }
102+
103+ function showLastChance() {
104+ // TODO
105+ }
106+
89107 Rectangle {
90108 anchors.fill: parent
91109 color: "black"
@@ -101,7 +119,7 @@ FocusScope {
101119
102120 infographics {
103121 height: 0.75 * parent.height
104− anchors.leftMargin: loginList.x + loginList.width
122+ anchors.leftMargin: loginAreaLoader.x + loginAreaLoader.width
105123 }
106124
107125 onTease: root.tease()
@@ -112,24 +130,96 @@ FocusScope {
112130 }
113131 }
114132
115− LoginList {
116− id: loginList
117− objectName: "loginList"
133+ Loader {
134+ id: loginAreaLoader
135+
136+ // True when LoginList is shown, false when SessionList is shown
137+ property bool loginListShown: true
138+ property bool sessionUpdated: false
139+ property string currentSession // Set as soon as LoginList is loaded
140+
141+ source: loginListShown ? "LoginList.qml" : "SessionsList.qml"
142+ onSourceChanged: loadingAnimation.running = true
118143
119144 anchors {
120145 left: parent.left
121146 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
122147 top: parent.top
123148 }
149+
124150 width: units.gu(29)
125− height: inputMethod && inputMethod.visible ? parent.height - inputMethod.keyboardRectangle.height
126− : parent.height
151+ height: inputMethod && inputMethod.visible ?
152+ parent.height - inputMethod.keyboardRectangle.height : parent.height
153+
127154 Behavior on height { UbuntuNumberAnimation {} }
128155
129− locked: root.locked
156+ UbuntuNumberAnimation {
157+ id: loadingAnimation
158+ target: loginAreaLoader.item
159+ property: "x"
160+ from: loader.item.width
161+ to: 0
162+ running: false
163+ }
164+
165+ Binding {
166+ target: loginAreaLoader.item
167+ property: "currentIndex"
168+ value: loginListShown ? root.currentIndex : null
169+ }
170+
171+ Binding {
172+ target: loginAreaLoader.item
173+ property: "locked"
174+ value: root.locked
175+ }
130176
131− onSelected: root.selected(index)
132− onResponded: root.responded(response)
177+ Binding {
178+ target: loginAreaLoader.item
179+ property: "model"
180+ value: loginListShown ? root.userModel : null
181+ }
182+
183+ // Only inform LoginList if the session isn't the user's default session
184+ // because LoginList gets the default session on its own
185+ Binding {
186+ target: loginAreaLoader.item
187+ property: "selectedSession"
188+ value: loginListShown && loginAreaLoader.sessionUpdated ?
189+ loginAreaLoader.currentSession : null
190+ }
191+
192+ Binding {
193+ target: loginAreaLoader.item
194+ property: "initiallySelectedSession"
195+ value: !loginListShown ? loginAreaLoader.currentSession : null
196+ }
197+
198+ Connections {
199+ target: loginListShown ? loginAreaLoader.item : null
200+ onSelected: root.selected(index)
201+ onResponded: root.responded(response)
202+ // The initially selected session lags behind the component completion
203+ // so this provides the initial session name when available
204+ onLoginListSessionChanged: {
205+ if (loginListShown && !loginAreaLoader.sessionUpdated) {
206+ loginAreaLoader.currentSession = loginAreaLoader.item.currentSession
207+ }
208+ }
209+
210+ onSessionChooserButtonClicked: loginListShown = false;
211+ ignoreUnknownSignals: true
212+ }
213+
214+ Connections {
215+ target: !loginListShown ? loginAreaLoader.item : null
216+ onSessionSelected: {
217+ loginAreaLoader.loginListShown = true
218+ loginAreaLoader.sessionUpdated = true
219+ loginAreaLoader.currentSession = sessionName
220+ }
221+ ignoreUnknownSignals: true
222+ }
133223 }
134224 }
135225}
qml/Greeter/graphics/session_icons/gnome_badge.pngnew file

Binary file not shown.

qml/Greeter/graphics/session_icons/plasma_badge.pngnew file

Binary file not shown.

qml/Greeter/graphics/session_icons/recovery_console_badge.pngnew file

Binary file not shown.

qml/Greeter/graphics/session_icons/ubuntu_badge.pngnew file

Binary file not shown.

qml/Greeter/graphics/session_icons/unknown_badge.pngnew file

Binary file not shown.