on xenial help sign in
Merge mterrys
commit310bdf27b630e051185fa79d3a6a1f14ed9b2f85 authorJosh Arenson <joshua.arenson@canonical.com> dateMon 20 Jun 2016, 15:17 (10 years ago) parenta6282516768946
8 files changed+280−111
qml/Components/FadingLabel.qml+42 qml/Greeter/CoverPage.qml+1 qml/Greeter/GreeterPrompt.qml+142 qml/Greeter/LoginAreaContainer.qml+19−8 qml/Greeter/LoginList.qml+46−70 qml/Greeter/WideView.qml+1−1 tests/qmltests/Greeter/tst_WideView.qml+21−28 tests/qmltests/tst_Shell.qml+8−4
qml/Components/FadingLabel.qmlnew file+42
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (C) 2016 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 QtGraphicalEffects 1.0
19+import Ubuntu.Components 1.3
20+
21+Label {
22+ property real fadeDistance: units.gu(8)
23+
24+ layer.enabled: contentWidth > width
25+ layer.effect: ShaderEffect {
26+ property real fadeThreshold: Math.min(1, Math.max(0, 1 - fadeDistance / width))
27+
28+ fragmentShader: "
29+ varying highp vec2 qt_TexCoord0;
30+ uniform lowp float qt_Opacity;
31+ uniform sampler2D source;
32+ uniform lowp float fadeThreshold;
33+ void main(void)
34+ {
35+ highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
36+ lowp float alpha = 1.0;
37+ if (qt_TexCoord0.x > fadeThreshold && fadeThreshold < 1.0)
38+ alpha = (1.0 - qt_TexCoord0.x) / (1.0 - fadeThreshold);
39+ gl_FragColor = sourceColor * alpha * qt_Opacity;
40+ }"
41+ }
42+}
qml/Greeter/CoverPage.qml+1
@@ -88,6 +88,7 @@ Showable {
8888 sourceSize.width: width
8989 }
9090
91+ // Darkens wallpaper so that we can read text on it and see infographic
9192 Rectangle {
9293 anchors.fill: parent
9394 color: "black"
qml/Greeter/GreeterPrompt.qmlnew file+142
@@ -0,0 +1,142 @@
1+/*
2+ * Copyright (C) 2016 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+
20+FocusScope {
21+ id: root
22+ implicitHeight: units.gu(5)
23+ focus: true
24+
25+ property bool isPrompt
26+ property bool isAlphanumeric
27+ property string text
28+ property bool isSecret
29+
30+ signal clicked()
31+ signal canceled()
32+ signal responded(string text)
33+
34+ function reset() {
35+ passwordInput.text = "";
36+ d.enabled = true;
37+ }
38+
39+ StyledItem {
40+ id: d
41+
42+ property bool enabled: true
43+ readonly property color textColor: passwordInput.enabled ? theme.palette.normal.raisedText
44+ : theme.palette.disabled.raisedText
45+ readonly property color selectedColor: passwordInput.enabled ? theme.palette.normal.raised
46+ : theme.palette.disabled.raised
47+ readonly property color drawColor: passwordInput.enabled ? theme.palette.normal.raisedSecondaryText
48+ : theme.palette.disabled.raisedSecondaryText
49+ readonly property color errorColor: passwordInput.enabled ? theme.palette.normal.negative
50+ : theme.palette.disabled.negative
51+ }
52+
53+ Rectangle {
54+ anchors.fill: parent
55+ border.width: units.dp(1)
56+ border.color: d.drawColor
57+ radius: units.gu(0.5)
58+ color: "transparent"
59+ }
60+
61+ AbstractButton {
62+ objectName: "promptButton"
63+ anchors.fill: parent
64+ visible: !root.isPrompt
65+ enabled: d.enabled
66+ focus: visible
67+
68+ onClicked: root.clicked()
69+
70+ Label {
71+ anchors.centerIn: parent
72+ color: d.textColor
73+ text: root.text
74+ }
75+ }
76+
77+ TextField {
78+ id: passwordInput
79+ objectName: "promptField"
80+ anchors.fill: parent
81+ visible: root.isPrompt
82+ enabled: d.enabled
83+ focus: visible
84+
85+ inputMethodHints: root.isAlphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
86+ echoMode: root.isSecret ? TextInput.Password : TextInput.Normal
87+ hasClearButton: false
88+
89+ readonly property real frameSpacing: units.gu(0.5)
90+
91+ style: Item {
92+ property color color: d.textColor
93+ property color selectedTextColor: d.selectedColor
94+ property color selectionColor: d.textColor
95+ property color borderColor: "transparent"
96+ property color backgroundColor: "transparent"
97+ property color errorColor: d.errorColor
98+ property real frameSpacing: passwordInput.frameSpacing
99+ anchors.fill: parent
100+ }
101+
102+ secondaryItem: [
103+ Icon {
104+ id: capsIcon
105+ name: "keyboard-caps-enabled"
106+ height: units.gu(3)
107+ width: units.gu(3)
108+ color: d.textColor
109+ visible: root.isSecret && false // TODO: detect when caps lock is on
110+ }
111+ ]
112+
113+ onAccepted: {
114+ if (!enabled)
115+ return;
116+ d.enabled = false;
117+ root.responded(text);
118+ }
119+
120+ Keys.onEscapePressed: root.canceled()
121+
122+ // We use our own custom placeholder label instead of the standard
123+ // TextField one because the standard one hardcodes baseText as the
124+ // palette color, whereas we want raisedSecondaryText.
125+ Label {
126+ id: hint
127+ anchors {
128+ left: parent.left
129+ right: parent.right
130+ verticalCenter: parent.verticalCenter
131+ leftMargin: units.gu(1.5)
132+ rightMargin: anchors.leftMargin +
133+ (capsIcon.visible ? capsIcon.width + passwordInput.frameSpacing
134+ : 0)
135+ }
136+ text: root.text
137+ visible: passwordInput.text == "" && !passwordInput.inputMethodComposing
138+ color: d.drawColor
139+ elide: Text.ElideRight
140+ }
141+ }
142+}
qml/Greeter/LoginAreaContainer.qml+19−8
@@ -15,13 +15,24 @@
1515 */
1616
1717import QtQuick 2.4
18−import "." 0.1
18+import Ubuntu.Components 1.3
1919
20−Rectangle {
21− height: units.gu(10)
22− color: Qt.rgba(0.1, 0.1, 0.1, 0.4)
23− border.color: Qt.rgba(0.4, 0.4, 0.4, 0.4)
24− border.width: units.dp(1)
25− radius: units.gu(1.5)
26− antialiasing: true
20+Item {
21+ BorderImage {
22+ anchors {
23+ fill: parent
24+ topMargin: -units.gu(1)
25+ leftMargin: -units.gu(1.5)
26+ rightMargin: -units.gu(1.5)
27+ bottomMargin: -units.gu(1.5)
28+ }
29+ source: "../Stages/graphics/dropshadow2gu.sci"
30+ opacity: 0.35
31+ }
32+
33+ UbuntuShape {
34+ anchors.fill: parent
35+ aspect: UbuntuShape.Flat
36+ backgroundColor: theme.palette.normal.raised
37+ }
2738}
qml/Greeter/LoginList.qml+46−70
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -15,11 +15,12 @@
1515 */
1616
1717import QtQuick 2.4
18+import QtGraphicalEffects 1.0
1819import Ubuntu.Components 1.3
1920import "../Components"
2021import "." 0.1
2122
22−Item {
23+StyledItem {
2324 id: root
2425
2526 property alias model: userList.model
@@ -29,7 +30,7 @@ Item {
2930
3031 readonly property int numAboveBelow: 4
3132 readonly property int cellHeight: units.gu(5)
32− readonly property int highlightedHeight: units.gu(10)
33+ readonly property int highlightedHeight: units.gu(15)
3334 readonly property int moveDuration: 200
3435 property string selectedSession
3536 property string currentSession: selectedSession ?
@@ -66,10 +67,9 @@ Item {
6667 }
6768
6869 function showPrompt(text, isSecret, isDefaultPrompt) {
69− passwordInput.text = "";
70− passwordInput.promptText = text;
71− passwordInput.enabled = true;
72− passwordInput.echoMode = isSecret ? TextInput.Password : TextInput.Normal;
70+ d.promptText = text;
71+ passwordInput.reset();
72+ passwordInput.isSecret = isSecret;
7373 if (wasPrompted) // stay in text field if second prompt
7474 passwordInput.focus = true;
7575 wasPrompted = true;
@@ -87,6 +87,16 @@ Item {
8787 root.resetAuthentication();
8888 }
8989
90+ QtObject {
91+ id: d
92+
93+ property string promptText
94+ }
95+
96+ theme: ThemeSettings {
97+ name: "Ubuntu.Components.Themes.Ambiance"
98+ }
99+
90100 Keys.onEscapePressed: {
91101 selected(currentIndex);
92102 }
@@ -99,10 +109,14 @@ Item {
99109 id: highlightItem
100110 anchors {
101111 left: parent.left
112+ leftMargin: units.gu(2)
102113 right: parent.right
114+ rightMargin: units.gu(2)
103115 verticalCenter: parent.verticalCenter
104116 }
105117
118+ height: root.highlightedHeight
119+
106120 z: sessionChooser.visible ? userList.z + 1 : z
107121
108122 // Use an AbstractButton due to icon limitations with Button
@@ -152,6 +166,8 @@ Item {
152166 objectName: "userList"
153167
154168 anchors.fill: parent
169+ anchors.leftMargin: units.gu(2)
170+ anchors.rightMargin: units.gu(2)
155171
156172 preferredHighlightBegin: userList.height / 2 - root.highlightedHeight / 2
157173 preferredHighlightEnd: userList.height / 2 - root.highlightedHeight / 2
@@ -198,7 +214,7 @@ Item {
198214 return 1 - Math.min(1, (Math.abs(highlightDist) + root.cellHeight) / ((root.numAboveBelow + 1) * root.cellHeight))
199215 }
200216
201− Label {
217+ FadingLabel {
202218 objectName: "username" + index
203219
204220 anchors {
@@ -206,13 +222,12 @@ Item {
206222 leftMargin: units.gu(2)
207223 right: parent.right
208224 rightMargin: units.gu(2)
209− top: parent.top
210− // Add an offset to topMargin for any items below the highlight
211− topMargin: units.gu(1) + (parent.belowHighlight ? parent.belowOffset : 0)
225+ bottom: parent.top
226+ // Add an offset to bottomMargin for any items below the highlight
227+ bottomMargin: -(units.gu(4) + (parent.belowHighlight ? parent.belowOffset : 0))
212228 }
213229 text: realName
214− color: "white"
215− elide: Text.ElideRight
230+ color: userList.currentIndex !== index ? theme.palette.normal.raised : theme.palette.normal.raisedText
216231
217232 Behavior on anchors.topMargin { NumberAnimation { duration: root.moveDuration; easing.type: Easing.InOutQuad; } }
218233 }
@@ -243,23 +258,22 @@ Item {
243258 }
244259 }
245260
246− Label {
261+ FadingLabel {
247262 id: infoLabel
248263 objectName: "infoLabel"
249264 anchors {
250265 bottom: passwordInput.top
251− left: parent.left
266+ left: highlightItem.left
252267 topMargin: units.gu(1)
253268 bottomMargin: units.gu(1)
254269 leftMargin: units.gu(2)
255270 rightMargin: units.gu(1)
256271 }
257272
258− color: "white"
273+ color: theme.palette.normal.raisedText
259274 width: root.width - anchors.leftMargin - anchors.rightMargin
260275 fontSize: "small"
261276 textFormat: Text.StyledText
262− clip: true
263277
264278 opacity: (userList.movingInternally || text == "") ? 0 : 1
265279 Behavior on opacity {
@@ -267,72 +281,36 @@ Item {
267281 }
268282 }
269283
270− TextField {
284+ GreeterPrompt {
271285 id: passwordInput
272286 objectName: "passwordInput"
273287 anchors {
274288 bottom: highlightItem.bottom
275− horizontalCenter: parent.horizontalCenter
276− margins: units.gu(1)
289+ horizontalCenter: highlightItem.horizontalCenter
290+ margins: units.gu(2)
277291 }
278− height: units.gu(4.5)
279− width: parent.width - anchors.margins * 2
292+ width: highlightItem.width - anchors.margins * 2
280293 opacity: userList.movingInternally ? 0 : 1
281294
282− inputMethodHints: root.alphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
295+ isPrompt: root.wasPrompted
296+ isAlphanumeric: root.alphanumeric
283297
284− property string promptText
285− placeholderText: root.wasPrompted ? promptText
286− : (root.locked ? i18n.tr("Retry")
287− : i18n.tr("Tap to unlock"))
298+ text: root.wasPrompted ? d.promptText
299+ : (root.locked ? i18n.tr("Retry")
300+ : i18n.tr("Log In"))
301+
302+ onClicked: root.tryToUnlock()
303+ onResponded: root.responded(text)
304+ onCanceled: root.selected(currentIndex)
288305
289306 Behavior on opacity {
290307 NumberAnimation { duration: 100 }
291308 }
292309
293− onAccepted: {
294− if (!enabled)
295− return;
296− root.focus = true; // so that it can handle Escape presses for us
297− enabled = false;
298− root.responded(text);
299− }
300− Keys.onEscapePressed: {
301− root.selected(currentIndex);
302− }
303−
304− Image {
305− anchors {
306− right: parent.right
307− rightMargin: units.gu(2)
308− verticalCenter: parent.verticalCenter
309− }
310− visible: !root.wasPrompted
311− source: "graphics/icon_arrow.png"
312− }
313−
314310 WrongPasswordAnimation {
315311 id: wrongPasswordAnimation
316312 target: passwordInput
317313 }
318−
319− Connections {
320− target: Qt.inputMethod
321− onVisibleChanged: {
322− if (!Qt.inputMethod.visible) {
323− passwordInput.focus = false;
324− }
325− }
326− }
327−
328− }
329−
330− MouseArea {
331− id: passwordMouseArea
332− objectName: "passwordMouseArea"
333− anchors.fill: passwordInput
334− enabled: !root.wasPrompted
335− onClicked: root.tryToUnlock()
336314 }
337315
338316 function resetAuthentication() {
@@ -340,10 +318,8 @@ Item {
340318 return;
341319 }
342320 infoLabel.text = "";
343− passwordInput.promptText = "";
344− passwordInput.text = "";
345− passwordInput.focus = false;
346− passwordInput.enabled = true;
321+ d.promptText = "";
322+ passwordInput.reset();
347323 root.wasPrompted = false;
348324 }
349325}
qml/Greeter/WideView.qml+1−1
@@ -149,7 +149,7 @@ FocusScope {
149149 top: parent.top
150150 }
151151
152− width: units.gu(29)
152+ width: units.gu(40)
153153 height: inputMethod && inputMethod.visible ?
154154 parent.height - inputMethod.keyboardRectangle.height : parent.height
155155
tests/qmltests/Greeter/tst_WideView.qml+21−28
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2016 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -22,11 +22,13 @@ import LightDM.IntegratedLightDM 0.1 as LightDM
2222import Ubuntu.Components 1.3
2323import Unity.Test 0.1 as UT
2424
25−Item {
25+StyledItem {
2626 id: root
2727 width: units.gu(120)
2828 height: units.gu(80)
2929
30+ theme.name: "Ubuntu.Components.Themes.SuruDark"
31+
3032 Binding {
3133 target: LightDM.Users
3234 property: "mockMode"
@@ -103,7 +105,7 @@ Item {
103105
104106 Rectangle {
105107 id: controls
106− color: "white"
108+ color: theme.palette.normal.background
107109 width: units.gu(40)
108110 height: parent.height
109111
@@ -481,8 +483,8 @@ Item {
481483 view.locked = true;
482484 view.showPrompt("Prompt", true, true);
483485 var passwordInput = findChild(view, "passwordInput");
484− compare(passwordInput.placeholderText, "Prompt");
485− compare(passwordInput.echoMode, TextInput.Password);
486+ compare(passwordInput.text, "Prompt");
487+ verify(passwordInput.isSecret);
486488 tap(passwordInput);
487489 typeString("password");
488490 keyClick(Qt.Key_Enter);
@@ -494,8 +496,8 @@ Item {
494496 view.locked = true;
495497 view.showPrompt("otp", false, false);
496498 var passwordInput = findChild(view, "passwordInput");
497− compare(passwordInput.placeholderText, "otp");
498− compare(passwordInput.echoMode, TextInput.Normal);
499+ compare(passwordInput.text, "otp");
500+ verify(!passwordInput.isSecret);
499501 tap(passwordInput);
500502 typeString("foo");
501503 keyClick(Qt.Key_Enter);
@@ -528,7 +530,6 @@ Item {
528530 var infoLabel = findChild(view, "infoLabel");
529531 compare(infoLabel.text, "Welcome to Unity Greeter<br><font color=\"#df382c\">This is an error</font><br>You should have seen three messages and this is a really long message too. wow so long much length");
530532 compare(infoLabel.textFormat, Text.StyledText);
531− compare(infoLabel.clip, true);
532533 verify(infoLabel.contentWidth > infoLabel.width);
533534 verify(infoLabel.opacity < 1);
534535 tryCompare(infoLabel, "opacity", 1);
@@ -540,15 +541,15 @@ Item {
540541 selectedSpy.clear();
541542 view.locked = true;
542543 view.showPrompt("Prompt", true, true);
543− var passwordInput = findChild(view, "passwordInput");
544− tap(passwordInput);
545− compare(passwordInput.focus, true);
546− compare(passwordInput.enabled, true);
544+ var promptField = findChild(view, "promptField");
545+ tap(promptField);
546+ compare(promptField.focus, true);
547+ compare(promptField.enabled, true);
547548
548549 typeString("password");
549550 keyClick(Qt.Key_Enter);
550− compare(passwordInput.focus, false);
551− compare(passwordInput.enabled, false);
551+ compare(promptField.focus, true);
552+ compare(promptField.enabled, false);
552553
553554 compare(selectedSpy.count, 0);
554555 keyClick(Qt.Key_Escape);
@@ -556,8 +557,8 @@ Item {
556557 compare(selectedSpy.signalArguments[0][0], 1);
557558
558559 view.reset();
559− compare(passwordInput.focus, false);
560− compare(passwordInput.enabled, true);
560+ compare(promptField.focus, false);
561+ compare(promptField.enabled, true);
561562 }
562563
563564 function test_unicode() {
@@ -566,17 +567,11 @@ Item {
566567 tryCompare(label, "text", "가나다라마");
567568 }
568569
569− function test_longName() {
570− var index = selectUser("long-name");
571− var label = findChild(view, "username" + index);
572− tryCompare(label, "truncated", true);
573− }
574−
575570 function test_promptless() {
576571 var passwordInput = findChild(view, "passwordInput");
577572
578573 view.locked = true;
579− compare(passwordInput.placeholderText, "Retry");
574+ compare(passwordInput.text, "Retry");
580575 tap(passwordInput);
581576 compare(respondedSpy.count, 0);
582577 compare(selectedSpy.count, 1);
@@ -584,7 +579,7 @@ Item {
584579 selectedSpy.clear();
585580
586581 view.locked = false;
587− compare(passwordInput.placeholderText, "Tap to unlock");
582+ compare(passwordInput.text, "Log In");
588583 tap(passwordInput);
589584 compare(selectedSpy.count, 0);
590585 compare(respondedSpy.count, 1);
@@ -616,11 +611,9 @@ Item {
616611 var passwordInput = findChild(view, "passwordInput");
617612
618613 verify(view.alphanumeric);
619− compare(passwordInput.inputMethodHints, Qt.ImhNone);
614+ verify(passwordInput.isAlphanumeric);
620615 view.alphanumeric = false;
621− compare(passwordInput.inputMethodHints, Qt.ImhDigitsOnly);
622− view.alphanumeric = true;
623− compare(passwordInput.inputMethodHints, Qt.ImhNone);
616+ verify(!passwordInput.isAlphanumeric);
624617 }
625618 }
626619}
tests/qmltests/tst_Shell.qml+8−4
@@ -810,10 +810,14 @@ Rectangle {
810810 var greeter = findChild(shell, "greeter")
811811 tryCompare(greeter, "fullyShown", true);
812812
813− var passwordMouseArea = findChild(shell, "passwordMouseArea")
814− tryCompare(passwordMouseArea, "enabled", isButton)
813+ var passwordInput = findChild(shell, "passwordInput");
814+
815+ var promptButton = findChild(passwordInput, "promptButton");
816+ tryCompare(promptButton, "visible", isButton);
817+
818+ var promptField = findChild(passwordInput, "promptField");
819+ tryCompare(promptField, "visible", !isButton);
815820
816− var passwordInput = findChild(shell, "passwordInput")
817821 mouseClick(passwordInput)
818822 }
819823
@@ -2364,7 +2368,7 @@ Rectangle {
23642368 function test_switchKeymap() {
23652369 // start with phone shell
23662370 loadShell("phone");
2367− shell.usageScenario = "shell";
2371+ shell.usageScenario = "phone";
23682372 waitForRendering(shell);
23692373 swipeAwayGreeter();
23702374