This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Walkthough.qml
192 lines (157 loc) · 5.75 KB
/
Walkthough.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/***************************************************************************
* Whatsoever ye do in word or deed, do all in the name of the *
* Lord Jesus, giving thanks to God and the Father by him. *
* - Colossians 3:17 *
* *
* Ubuntu UI Extras - A collection of QML widgets not available *
* in the default Ubuntu UI Toolkit *
* Copyright (C) 2013 Michael Spencer <[email protected]> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Components.Popups 1.0
import Ubuntu.Components.ListItems 1.0 as ListItem
Page {
id: root
property list<Component> model
property string appName
property color completedPage
property color incompletePage
property bool exitable: false
property bool swipingEnabled: true
signal finished
property bool showSkipButton: true
property bool showFooter: true
property alias currentIndex: listView.currentIndex
property alias currentItem: listView.currentItem
property alias pageCount: listView.count
onFinished: {
if (exitable) {
pageStack.pop()
} else {
hideAnimation.start()
}
}
SequentialAnimation {
id: hideAnimation
UbuntuNumberAnimation {
duration: UbuntuAnimation.SlowDuration * 1/2
target: root
property: "opacity"
from: 1; to: 0;
}
ScriptAction {
script: {
pageStack.pop(root)
}
}
}
Component.onCompleted: mainView.forceActiveFocus()
Keys.onLeftPressed: {
if (list.currentIndex > 0)
list.currentIndex--
}
Keys.onRightPressed: {
if (list.currentIndex < list.count - 1)
list.currentIndex++
}
// Label to skip the walkthrough. Only visible on the first slide
Label {
id: skipLabel
objectName:"skipButton"
opacity: 0.5
fontSize: "small"
width: contentWidth
text: listView.currentIndex === 0 ? i18n.tr("Already used %1? <b>Skip the tutorial</b>").arg(appName) : i18n.tr("Skip")
visible: showSkipButton
anchors {
top: parent.top
left: parent.left
margins: units.gu(2)
}
MouseArea {
anchors.fill: parent
onClicked: root.finished()
}
}
ListView {
id: listView
anchors {
left: parent.left
right: parent.right
top: showSkipButton ? skipLabel.bottom : parent.top
bottom: divider.top
}
model: root.model
snapMode: ListView.SnapOneItem
orientation: Qt.Horizontal
highlightMoveDuration: UbuntuAnimation.FastDuration
highlightRangeMode: ListView.StrictlyEnforceRange
highlightFollowsCurrentItem: true
interactive: swipingEnabled
delegate: Item {
width: listView.width
height: listView.height
clip: true
Loader {
anchors {
fill: parent
margins: units.gu(2)
}
sourceComponent: modelData
}
}
}
ListItem.ThinDivider {
id: divider
anchors.bottom: footer.top
}
Row {
id: footer
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
height: units.gu(6)
anchors.bottomMargin: showFooter ? 0 : -(footer.height + divider.height)
Behavior on anchors.bottomMargin {
UbuntuNumberAnimation {
duration: UbuntuAnimation.SlowDuration
}
}
spacing: (height - size)/2
property real size: units.gu(2)
Repeater {
model: listView.count
delegate: Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: footer.size
height: width
radius: width/2
color: /*listView.currentIndex == index ? Qt.rgba(0,0,0,0.4) : */listView.currentIndex >= index ? colors["green"] : colors["default"]
Behavior on color {
ColorAnimation {
duration: UbuntuAnimation.FastDuration
}
}
MouseArea {
anchors.fill: parent
onClicked: {
listView.currentIndex = index
}
}
}
}
}
}