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
|
/*
* Copyright (C) 2013 Canonical, Ltd.
*
* 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; version 3.
*
* 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 0.1
import Unity 0.1
import Utils 0.1
import "../Components"
Showable {
id: dash
objectName: "dash"
visible: shown
property alias contentProgress: dashContent.contentProgress
property string showScopeOnLoaded: "home.scope"
property real contentScale: 1.0
function setCurrentScope(scopeId, animate, reset) {
var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId)
if (scopeIndex == -1) {
console.warn("No match for scope with id: %1".arg(scopeId))
return
}
if (scopeIndex == dashContent.currentIndex && !reset) {
// the scope is already the current one
return
}
dashContent.setCurrentScopeAtIndex(scopeIndex, animate, reset)
}
SortFilterProxyModel {
id: filteredScopes
model: Scopes {
id: scopes
}
dynamicSortFilter: true
filterRole: Scopes.RoleVisible
filterRegExp: RegExp("^true$")
}
DashContent {
id: dashContent
objectName: "dashContent"
anchors.fill: parent
model: filteredScopes
scopes: scopes
onMovementStarted: dashbar.startNavigation()
onMovementEnded: dashbar.stopNavigation()
onContentFlickStarted: dashbar.finishNavigation()
onContentEndReached: dashbar.finishNavigation()
onPreviewShown: dashbar.finishNavigation()
onScopeLoaded: {
if (scopeId == dash.showScopeOnLoaded) {
dash.setCurrentScope(scopeId, false, false)
dash.showScopeOnLoaded = ""
}
}
scale: dash.contentScale
clip: scale != 1.0
}
DashBar {
id: dashbar
objectName: "dashbar"
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
model: filteredScopes
currentIndex: dashContent.currentIndex
onItemSelected: dashContent.setCurrentScopeAtIndex(index, true, false)
opacity: dash.contentScale == 1.0 ? 1.0 : 0.0
Behavior on opacity { NumberAnimation { easing.type: Easing.OutQuad; duration: 150 } }
}
}
|