on 08736db help sign in
unity8/qml/Tutorial/TutorialLeft.qml
100 lines 2.8 kB history raw
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 */
17import QtQuick 2.3
18import Ubuntu.Components 1.1
19import "." as LocalComponents
21TutorialPage {
22 id: root
24 property var launcher
26 title: i18n.tr("Open the launcher")
27 text: i18n.tr("Short swipe from the left edge.")
29 textXOffset: root.launcher.x + root.launcher.visibleWidth
31 Connections {
32 target: root.launcher
34 onStateChanged: {
35 if (root.launcher.state === "visible") {
36 finishTimer.start();
37 }
38 }
40 onDash: {
41 finishTimer.stop();
42 root.showError();
43 root.launcher.hide();
44 }
45 }
47 SequentialAnimation {
48 id: teaseAnimation
49 objectName: "teaseAnimation"
50 paused: running && root.paused
51 running: !slider.active && root.launcher.visibleWidth === 0 && root.shown
52 loops: Animation.Infinite
53 property real bounce: 0
54 readonly property real maxBounce: units.gu(2)
56 UbuntuNumberAnimation {
57 target: teaseAnimation
58 property: "bounce"
59 to: teaseAnimation.maxBounce
60 duration: UbuntuAnimation.SleepyDuration
61 }
62 UbuntuNumberAnimation {
63 target: teaseAnimation
64 property: "bounce"
65 to: 0
66 duration: UbuntuAnimation.SleepyDuration
67 }
68 }
70 Binding {
71 target: root.launcher
72 property: "x"
73 value: Math.min(root.launcher.panelWidth - root.launcher.visibleWidth, teaseAnimation.bounce)
74 }
76 Timer {
77 id: finishTimer
78 interval: 1
79 onTriggered: {
80 root.hide();
81 root.launcher.x = 0; // make sure to reset launcher before we go
82 }
83 }
85 foreground {
86 children: [
87 LocalComponents.Slider {
88 id: slider
89 anchors {
90 left: parent.left
91 top: parent.top
92 topMargin: root.textBottom + units.gu(3)
93 }
94 offset: root.launcher.x + root.launcher.visibleWidth + root.launcher.progress
95 active: root.launcher.dragging
96 shortSwipe: true
97 }
98 ]
99 }