Unity 8
TutorialLeft.qml
1 /*
2  * Copyright (C) 2014,2015 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 import "." as LocalComponents
20 
21 TutorialPage {
22  id: root
23 
24  property var launcher
25 
26  title: i18n.tr("Open the launcher")
27  text: i18n.tr("Short swipe from the left edge.")
28 
29  textXOffset: root.launcher.x + root.launcher.visibleWidth
30 
31  Connections {
32  target: root.launcher
33 
34  onStateChanged: {
35  if (root.launcher.state === "visible") {
36  finishTimer.start();
37  }
38  }
39 
40  onDash: {
41  finishTimer.stop();
42  root.showError();
43  root.launcher.hide();
44  }
45  }
46 
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)
55 
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  }
69 
70  Binding {
71  target: root.launcher
72  when: root.shown
73  property: "x"
74  value: Math.min(root.launcher.panelWidth - root.launcher.visibleWidth, teaseAnimation.bounce)
75  }
76 
77  Timer {
78  id: finishTimer
79  interval: 1
80  onTriggered: {
81  root.hide();
82  root.launcher.x = 0; // make sure to reset launcher before we go
83  }
84  }
85 
86  foreground {
87  children: [
88  LocalComponents.Slider {
89  id: slider
90  anchors {
91  left: parent.left
92  top: parent.top
93  topMargin: root.textBottom + units.gu(3)
94  }
95  offset: root.launcher.x + root.launcher.visibleWidth + root.launcher.progress
96  active: root.launcher.dragging
97  shortSwipe: true
98  }
99  ]
100  }
101 }