on xenial help sign in
Add bottom edge pages
commit8160336b0fef648a1883f9e4f1f3f5d8f354a6fb authorMichael Terry <michael.terry@canonical.com> dateTue 23 Dec 2014, 18:08 (12 years ago) parent5bd1a67
7 files changed+167−3
qml/Shell.qml+1 qml/Tutorial/Slider.qml+1−1 qml/Tutorial/Tutorial.qml+7 qml/Tutorial/TutorialBottom.qml+82 qml/Tutorial/TutorialBottomFinish.qml+47 qml/Tutorial/TutorialContent.qml+28−1 qml/Tutorial/TutorialLeftFinish.qml+1−1
qml/Shell.qml+1
@@ -854,6 +854,7 @@ Item {
854854 panel: panel
855855 stages: stages
856856 overlay: overlay
857+ edgeSize: shell.edgeSize
857858
858859 onFinished: AccountsService.demoEdges = false
859860 }
qml/Tutorial/Slider.qml+1−1
@@ -37,7 +37,7 @@ Item {
3737 readonly property real margin: units.gu(0.5)
3838 readonly property real arrowSize: root.height - margin * 2
3939 readonly property real dotSize: units.dp(1)
40− readonly property real slideOffset: Math.min(root.offset, target.x)
40+ readonly property real slideOffset: MathUtils.clamp(root.offset, 0, target.x)
4141 }
4242
4343 implicitWidth: shortSwipe ? units.gu(15) : units.gu(27.5)
qml/Tutorial/Tutorial.qml+7
@@ -22,6 +22,7 @@ Item {
2222
2323 property alias active: loader.active
2424 property bool paused
25+ property real edgeSize
2526
2627 property Item launcher
2728 property Item panel
@@ -47,6 +48,12 @@ Item {
4748 value: root.paused
4849 }
4950
51+ Binding {
52+ target: loader.item
53+ property: "edgeSize"
54+ value: root.edgeSize
55+ }
56+
5057 Binding {
5158 target: loader.item
5259 property: "launcher"
qml/Tutorial/TutorialBottom.qmlnew file+82
@@ -0,0 +1,82 @@
1+/*
2+ * Copyright (C) 2014 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.3
18+import Ubuntu.Components 1.1
19+import Ubuntu.Gestures 0.1
20+import "../Components"
21+import "." as LocalComponents
22+
23+TutorialPage {
24+ id: root
25+
26+ property alias edgeSize: dragArea.height
27+
28+ title: i18n.tr("Open special menus")
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
32+
33+ foreground {
34+ children: [
35+ LocalComponents.Slider {
36+ id: slider
37+ anchors {
38+ bottom: parent.bottom
39+ bottomMargin: width / 2 - height / 2
40+ horizontalCenter: parent.horizontalCenter
41+ }
42+ rotation: -90
43+ offset: dragArea.useTouchY ? -dragArea.touchY : 0
44+ active: dragArea.dragging
45+
46+ Behavior on offset {
47+ id: offsetAnimation
48+ UbuntuNumberAnimation {}
49+ }
50+ }
51+ ]
52+ }
53+
54+ EdgeDragArea {
55+ id: dragArea
56+ direction: Direction.Upwards
57+ anchors {
58+ bottom: parent.bottom
59+ left: parent.left
60+ right: parent.right
61+ }
62+
63+ property bool useTouchY
64+
65+ onDraggingChanged: {
66+ if (!dragging) {
67+ if (slider.percent >= 0.85) {
68+ root.hide();
69+ } else if (slider.percent >= 0.15) {
70+ root.showError();
71+ }
72+ }
73+
74+ // We use a separate vars here rather than just directly looking at
75+ // 'dragging' because we want to preserve our 'slider.offset'
76+ // value during the above percent check. Now that we made it,
77+ // we can have 'slider.offset' go back to zero.
78+ offsetAnimation.enabled = !dragging;
79+ useTouchY = dragging;
80+ }
81+ }
82+}
qml/Tutorial/TutorialBottomFinish.qmlnew file+47
@@ -0,0 +1,47 @@
1+/*
2+ * Copyright (C) 2014 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.3
18+import Ubuntu.Components 1.1
19+
20+TutorialPage {
21+ id: root
22+
23+ title: i18n.tr("This action does different things for different apps")
24+ text: i18n.tr("Tap here to finish.")
25+ fullTextWidth: true
26+
27+ foreground {
28+ children: [
29+ Image {
30+ objectName: "tick"
31+ anchors {
32+ horizontalCenter: parent.horizontalCenter
33+ top: parent.top
34+ topMargin: root.textBottom + units.gu(3)
35+ }
36+ source: Qt.resolvedUrl("graphics/tick.png")
37+ height: units.gu(6.5)
38+ width: units.gu(6.5)
39+
40+ MouseArea {
41+ anchors.fill: parent
42+ onClicked: root.hide()
43+ }
44+ }
45+ ]
46+ }
47+}
qml/Tutorial/TutorialContent.qml+28−1
@@ -33,6 +33,7 @@ Item {
3333 readonly property bool running: loader.sourceComponent !== null
3434
3535 property bool paused: false
36+ property real edgeSize
3637
3738 signal finished()
3839
@@ -122,9 +123,35 @@ Item {
122123 parent: root.stages
123124 anchors.fill: parent
124125 textXOffset: root.launcher.panelWidth
126+
127+ onFinished: {
128+ root.launcher.hide();
129+ loader.load(bottomComponent);
130+ }
131+ }
132+ }
133+
134+ Component {
135+ id: bottomComponent
136+ TutorialBottom {
137+ objectName: "tutorialBottom"
138+ parent: root.stages
139+ anchors.fill: parent
140+ edgeSize: root.edgeSize
141+
142+ onFinished: loader.load(bottomFinishComponent)
143+ }
144+ }
145+
146+ Component {
147+ id: bottomFinishComponent
148+ TutorialBottomFinish {
149+ objectName: "tutorialBottomFinish"
150+ parent: root.stages
151+ anchors.fill: parent
125152 backgroundFadesOut: true
126153
127− onFinished: root.launcher.hide()
154+ onFinished: root.finish()
128155 }
129156 }
130157}
qml/Tutorial/TutorialLeftFinish.qml+1−1
@@ -21,7 +21,7 @@ TutorialPage {
2121 id: root
2222
2323 title: i18n.tr("These are the shortcuts to favorite apps")
24− text: i18n.tr("Tap here to finish.")
24+ text: i18n.tr("Tap here to continue.")
2525 fullTextWidth: true
2626
2727 foreground {