on xenial help sign in
Merge from -refactor
commit1e8c5fc79c2636dd4afc21d7355cfe7983981c7f authorMichael Terry <michael.terry@canonical.com> dateFri 9 Jan 2015, 16:51 (12 years ago) parent8d534b9940e1fc
6 files changed+59−35
qml/Tutorial/Slider.qml+5−6 qml/Tutorial/TutorialBottom.qml−1 qml/Tutorial/TutorialLeft.qml+1−2 qml/Tutorial/TutorialPage.qml+45−21 qml/Tutorial/TutorialRight.qml−1 tests/qmltests/Tutorial/tst_Tutorial.qml+8−4
qml/Tutorial/Slider.qml+5−6
@@ -34,6 +34,7 @@ Item {
3434
3535 QtObject {
3636 id: d
37+ readonly property color trayColor: "#424141"
3738 readonly property real margin: units.gu(0.5)
3839 readonly property real arrowSize: root.height - margin * 2
3940 readonly property real dotSize: units.dp(1)
@@ -45,8 +46,7 @@ Item {
4546 implicitHeight: units.gu(6.5)
4647
4748 Rectangle {
48− color: "black"
49− opacity: 0.4
49+ color: d.trayColor
5050 anchors.fill: parent
5151 anchors.rightMargin: clipBox.width - 1
5252 }
@@ -63,8 +63,7 @@ Item {
6363 width: parent.height / 2
6464
6565 Rectangle {
66− color: "black"
67− opacity: 0.4
66+ color: d.trayColor
6867 anchors.top: parent.top
6968 anchors.bottom: parent.bottom
7069 anchors.right: parent.right
@@ -77,8 +76,8 @@ Item {
7776 id: target
7877 width: d.arrowSize
7978 height: d.arrowSize
80− color: "black"
81− chevronOpacity: 0.2
79+ color: "#73000000"
80+ chevronOpacity: 0.52
8281 anchors.right: parent.right
8382 anchors.rightMargin: d.margin
8483 anchors.verticalCenter: parent.verticalCenter
qml/Tutorial/TutorialBottom.qml−1
@@ -27,7 +27,6 @@ TutorialPage {
2727
2828 title: i18n.tr("Open special menus")
2929 text: i18n.tr("Swipe up from the bottom edge.")
30− errorText: i18n.tr("You almost got it!") + "\n" + i18n.tr("Try again.")
3130 fullTextWidth: true
3231
3332 foreground {
qml/Tutorial/TutorialLeft.qml+1−2
@@ -25,9 +25,8 @@ TutorialPage {
2525
2626 title: i18n.tr("Open the launcher")
2727 text: i18n.tr("Short swipe from the left edge.")
28− errorText: i18n.tr("Too far!") + "\n" + i18n.tr("Try again.")
2928
30− textXOffset: root.launcher.visibleWidth
29+ textXOffset: root.launcher.x + root.launcher.visibleWidth
3130
3231 Connections {
3332 target: root.launcher
qml/Tutorial/TutorialPage.qml+45−21
@@ -27,9 +27,6 @@ Showable {
2727 // This is the block of text displayed below the header
2828 property alias text: textLabel.text
2929
30− // This is the block of text displayed during an error
31− property alias errorText: errorLabel.text
32−
3330 // Whether animations are paused
3431 property bool paused
3532
@@ -46,7 +43,7 @@ Showable {
4643 property alias foreground: foregroundExtra
4744
4845 // 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)
5047
5148 // The MouseArea that eats events (so you can adjust size as you will)
5249 property alias mouseArea: mouseArea
@@ -161,21 +158,41 @@ Showable {
161158 font.pixelSize: units.gu(2.5)
162159 }
163160
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.
164165 Label {
165− id: errorLabel
166− objectName: "errorLabel"
166+ id: errorTitleLabel
167+ objectName: "errorTitleLabel"
167168 anchors {
168− top: parent.verticalCenter
169− topMargin: d.verticalOffset + root.textYOffset
170− left: parent.left
171− leftMargin: d.sideMargin + d.textXOffset
169+ top: titleLabel.top
170+ left: titleLabel.left
172171 }
173− width: parent.width - d.sideMargin * 2
174− horizontalAlignment: Text.AlignLeft
175− wrapMode: Text.Wrap
176− font.weight: Font.Light
177− font.pixelSize: units.gu(3.5)
172+ width: titleLabel.width
173+ horizontalAlignment: titleLabel.horizontalAlignment
174+ wrapMode: titleLabel.wrapMode
175+ font.weight: titleLabel.font.weight
176+ font.pixelSize: titleLabel.font.pixelSize
178177 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.")
179196 }
180197 }
181198
@@ -191,14 +208,14 @@ Showable {
191208 when: errorTimer.running
192209 PropertyChanges { target: titleLabel; opacity: 0 }
193210 PropertyChanges { target: textLabel; opacity: 0 }
194− PropertyChanges { target: errorLabel; opacity: 1 }
211+ PropertyChanges { target: errorTitleLabel; opacity: 1 }
212+ PropertyChanges { target: errorTextLabel; opacity: 1 }
195213 }
196214
197215 transitions: Transition {
198216 to: "errorState"
199217 reversible: true
200218 SequentialAnimation {
201− id: showErrorAnimation
202219 ParallelAnimation {
203220 StandardAnimation {
204221 target: titleLabel
@@ -211,10 +228,17 @@ Showable {
211228 duration: UbuntuAnimation.BriskDuration
212229 }
213230 }
214− StandardAnimation {
215− target: errorLabel
216− property: "opacity"
217− duration: UbuntuAnimation.BriskDuration
231+ ParallelAnimation {
232+ StandardAnimation {
233+ target: errorTitleLabel
234+ property: "opacity"
235+ duration: UbuntuAnimation.BriskDuration
236+ }
237+ StandardAnimation {
238+ target: errorTextLabel
239+ property: "opacity"
240+ duration: UbuntuAnimation.BriskDuration
241+ }
218242 }
219243 }
220244 }
qml/Tutorial/TutorialRight.qml−1
@@ -30,7 +30,6 @@ TutorialPage {
3030
3131 title: i18n.tr("To view open apps")
3232 text: i18n.tr("Long swipe from the right edge.")
33− errorText: i18n.tr("You almost got it!") + "\n" + i18n.tr("Try again.")
3433
3534 textOpacity: 1 - slider.percent
3635
tests/qmltests/Tutorial/tst_Tutorial.qml+8−4
@@ -276,10 +276,12 @@ Item {
276276 var launcher = findChild(shell, "launcher");
277277 touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
278278
279− var errorLabel = findChild(left, "errorLabel");
279+ var errorTextLabel = findChild(left, "errorTextLabel");
280+ var errorTitleLabel = findChild(left, "errorTitleLabel");
280281 tryCompare(launcher, "state", ""); // launcher goes away
281282 tryCompare(left, "shown", true); // still on left page
282− tryCompare(errorLabel, "opacity", 1); // show error
283+ tryCompare(errorTextLabel, "opacity", 1); // show error
284+ tryCompare(errorTitleLabel, "opacity", 1); // show error
283285 }
284286
285287 function test_launcherDragBack() {
@@ -322,9 +324,11 @@ Item {
322324
323325 touchFlick(shell, halfWidth, shell.height, halfWidth, shell.height * 0.8);
324326
325− var errorLabel = findChild(bottom, "errorLabel");
327+ var errorTextLabel = findChild(bottom, "errorTextLabel");
328+ var errorTitleLabel = findChild(bottom, "errorTitleLabel");
326329 tryCompare(bottom, "shown", true); // still on bottom page
327− tryCompare(errorLabel, "opacity", 1); // show error
330+ tryCompare(errorTextLabel, "opacity", 1); // show error
331+ tryCompare(errorTitleLabel, "opacity", 1); // show error
328332 }
329333
330334 function test_interrupted() {