on xenial help sign in
Merge from -refactor
1e8c5fcMichael Terry
qml/Tutorial/Slider.qml+5−6
@@ -34,6 +34,7 @@ Item {
34
34
35 QtObject {
35 QtObject {
36 id: d
36 id: d
37+ readonly property color trayColor: "#424141"
37 readonly property real margin: units.gu(0.5)
38 readonly property real margin: units.gu(0.5)
38 readonly property real arrowSize: root.height - margin * 2
39 readonly property real arrowSize: root.height - margin * 2
39 readonly property real dotSize: units.dp(1)
40 readonly property real dotSize: units.dp(1)
@@ -45,8 +46,7 @@ Item {
45 implicitHeight: units.gu(6.5)
46 implicitHeight: units.gu(6.5)
46
47
47 Rectangle {
48 Rectangle {
48− color: "black"
49+ color: d.trayColor
49− opacity: 0.4
50 anchors.fill: parent
50 anchors.fill: parent
51 anchors.rightMargin: clipBox.width - 1
51 anchors.rightMargin: clipBox.width - 1
52 }
52 }
@@ -63,8 +63,7 @@ Item {
63 width: parent.height / 2
63 width: parent.height / 2
64
64
65 Rectangle {
65 Rectangle {
66− color: "black"
66+ color: d.trayColor
67− opacity: 0.4
68 anchors.top: parent.top
67 anchors.top: parent.top
69 anchors.bottom: parent.bottom
68 anchors.bottom: parent.bottom
70 anchors.right: parent.right
69 anchors.right: parent.right
@@ -77,8 +76,8 @@ Item {
77 id: target
76 id: target
78 width: d.arrowSize
77 width: d.arrowSize
79 height: d.arrowSize
78 height: d.arrowSize
80− color: "black"
79+ color: "#73000000"
81− chevronOpacity: 0.2
80+ chevronOpacity: 0.52
82 anchors.right: parent.right
81 anchors.right: parent.right
83 anchors.rightMargin: d.margin
82 anchors.rightMargin: d.margin
84 anchors.verticalCenter: parent.verticalCenter
83 anchors.verticalCenter: parent.verticalCenter
qml/Tutorial/TutorialBottom.qml−1
@@ -27,7 +27,6 @@ TutorialPage {
27
27
28 title: i18n.tr("Open special menus")
28 title: i18n.tr("Open special menus")
29 text: i18n.tr("Swipe up from the bottom edge.")
29 text: i18n.tr("Swipe up from the bottom edge.")
30− errorText: i18n.tr("You almost got it!") + "\n" + i18n.tr("Try again.")
31 fullTextWidth: true
30 fullTextWidth: true
32
31
33 foreground {
32 foreground {
qml/Tutorial/TutorialLeft.qml+1−2
@@ -25,9 +25,8 @@ TutorialPage {
25
25
26 title: i18n.tr("Open the launcher")
26 title: i18n.tr("Open the launcher")
27 text: i18n.tr("Short swipe from the left edge.")
27 text: i18n.tr("Short swipe from the left edge.")
28− errorText: i18n.tr("Too far!") + "\n" + i18n.tr("Try again.")
29
28
30− textXOffset: root.launcher.visibleWidth
29+ textXOffset: root.launcher.x + root.launcher.visibleWidth
31
30
32 Connections {
31 Connections {
33 target: root.launcher
32 target: root.launcher
qml/Tutorial/TutorialPage.qml+45−21
@@ -27,9 +27,6 @@ Showable {
27 // This is the block of text displayed below the header
27 // This is the block of text displayed below the header
28 property alias text: textLabel.text
28 property alias text: textLabel.text
29
29
30− // This is the block of text displayed during an error
31− property alias errorText: errorLabel.text
32−
33 // Whether animations are paused
30 // Whether animations are paused
34 property bool paused
31 property bool paused
35
32
@@ -46,7 +43,7 @@ Showable {
46 property alias foreground: foregroundExtra
43 property alias foreground: foregroundExtra
47
44
48 // The text label bottom, so you can position elements relative to it
45 // The text label bottom, so you can position elements relative to it
49− property real textBottom: textLabel.y + textLabel.height
46+ readonly property real textBottom: Math.max(textLabel.y + textLabel.height, errorTextLabel.y + errorTextLabel.height)
50
47
51 // The MouseArea that eats events (so you can adjust size as you will)
48 // The MouseArea that eats events (so you can adjust size as you will)
52 property alias mouseArea: mouseArea
49 property alias mouseArea: mouseArea
@@ -161,21 +158,41 @@ Showable {
161 font.pixelSize: units.gu(2.5)
158 font.pixelSize: units.gu(2.5)
162 }
159 }
163
160
161+ // We use two separate labels like this rather than just changing
162+ // the text of the above labels because we want to know where to place
163+ // sliders (via root.textBottom) without having that place change
164+ // as the text changes length.
164 Label {
165 Label {
165− id: errorLabel
166+ id: errorTitleLabel
166− objectName: "errorLabel"
167+ objectName: "errorTitleLabel"
167 anchors {
168 anchors {
168− top: parent.verticalCenter
169+ top: titleLabel.top
169− topMargin: d.verticalOffset + root.textYOffset
170− left: parent.left
170+ left: titleLabel.left
171− leftMargin: d.sideMargin + d.textXOffset
172 }
171 }
173− width: parent.width - d.sideMargin * 2
172+ width: titleLabel.width
174− horizontalAlignment: Text.AlignLeft
173+ horizontalAlignment: titleLabel.horizontalAlignment
175− wrapMode: Text.Wrap
174+ wrapMode: titleLabel.wrapMode
176− font.weight: Font.Light
175+ font.weight: titleLabel.font.weight
177− font.pixelSize: units.gu(3.5)
176+ font.pixelSize: titleLabel.font.pixelSize
178 opacity: 0
177 opacity: 0
178+ text: i18n.tr("You almost got it!")
179+ }
180+
181+ Label {
182+ id: errorTextLabel
183+ objectName: "errorTextLabel"
184+ anchors {
185+ top: errorTitleLabel.bottom
186+ topMargin: textLabel.anchors.topMargin
187+ left: textLabel.left
188+ }
189+ width: textLabel.width
190+ horizontalAlignment: textLabel.horizontalAlignment
191+ wrapMode: textLabel.wrapMode
192+ font.weight: textLabel.font.weight
193+ font.pixelSize: textLabel.font.pixelSize
194+ opacity: 0
195+ text: i18n.tr("Try again.")
179 }
196 }
180 }
197 }
181
198
@@ -191,14 +208,14 @@ Showable {
191 when: errorTimer.running
208 when: errorTimer.running
192 PropertyChanges { target: titleLabel; opacity: 0 }
209 PropertyChanges { target: titleLabel; opacity: 0 }
193 PropertyChanges { target: textLabel; opacity: 0 }
210 PropertyChanges { target: textLabel; opacity: 0 }
194− PropertyChanges { target: errorLabel; opacity: 1 }
211+ PropertyChanges { target: errorTitleLabel; opacity: 1 }
212+ PropertyChanges { target: errorTextLabel; opacity: 1 }
195 }
213 }
196
214
197 transitions: Transition {
215 transitions: Transition {
198 to: "errorState"
216 to: "errorState"
199 reversible: true
217 reversible: true
200 SequentialAnimation {
218 SequentialAnimation {
201− id: showErrorAnimation
202 ParallelAnimation {
219 ParallelAnimation {
203 StandardAnimation {
220 StandardAnimation {
204 target: titleLabel
221 target: titleLabel
@@ -211,10 +228,17 @@ Showable {
211 duration: UbuntuAnimation.BriskDuration
228 duration: UbuntuAnimation.BriskDuration
212 }
229 }
213 }
230 }
231+ ParallelAnimation {
214− StandardAnimation {
232+ StandardAnimation {
215− target: errorLabel
233+ target: errorTitleLabel
234+ property: "opacity"
235+ duration: UbuntuAnimation.BriskDuration
236+ }
237+ StandardAnimation {
238+ target: errorTextLabel
216− property: "opacity"
239+ property: "opacity"
217− duration: UbuntuAnimation.BriskDuration
240+ duration: UbuntuAnimation.BriskDuration
241+ }
218 }
242 }
219 }
243 }
220 }
244 }
qml/Tutorial/TutorialRight.qml−1
@@ -30,7 +30,6 @@ TutorialPage {
30
30
31 title: i18n.tr("To view open apps")
31 title: i18n.tr("To view open apps")
32 text: i18n.tr("Long swipe from the right edge.")
32 text: i18n.tr("Long swipe from the right edge.")
33− errorText: i18n.tr("You almost got it!") + "\n" + i18n.tr("Try again.")
34
33
35 textOpacity: 1 - slider.percent
34 textOpacity: 1 - slider.percent
36
35
tests/qmltests/Tutorial/tst_Tutorial.qml+8−4
@@ -276,10 +276,12 @@ Item {
276 var launcher = findChild(shell, "launcher");
276 var launcher = findChild(shell, "launcher");
277 touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
277 touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
278
278
279− var errorLabel = findChild(left, "errorLabel");
279+ var errorTextLabel = findChild(left, "errorTextLabel");
280+ var errorTitleLabel = findChild(left, "errorTitleLabel");
280 tryCompare(launcher, "state", ""); // launcher goes away
281 tryCompare(launcher, "state", ""); // launcher goes away
281 tryCompare(left, "shown", true); // still on left page
282 tryCompare(left, "shown", true); // still on left page
283+ tryCompare(errorTextLabel, "opacity", 1); // show error
282− tryCompare(errorLabel, "opacity", 1); // show error
284+ tryCompare(errorTitleLabel, "opacity", 1); // show error
283 }
285 }
284
286
285 function test_launcherDragBack() {
287 function test_launcherDragBack() {
@@ -322,9 +324,11 @@ Item {
322
324
323 touchFlick(shell, halfWidth, shell.height, halfWidth, shell.height * 0.8);
325 touchFlick(shell, halfWidth, shell.height, halfWidth, shell.height * 0.8);
324
326
325− var errorLabel = findChild(bottom, "errorLabel");
327+ var errorTextLabel = findChild(bottom, "errorTextLabel");
328+ var errorTitleLabel = findChild(bottom, "errorTitleLabel");
326 tryCompare(bottom, "shown", true); // still on bottom page
329 tryCompare(bottom, "shown", true); // still on bottom page
330+ tryCompare(errorTextLabel, "opacity", 1); // show error
327− tryCompare(errorLabel, "opacity", 1); // show error
331+ tryCompare(errorTitleLabel, "opacity", 1); // show error
328 }
332 }
329
333
330 function test_interrupted() {
334 function test_interrupted() {