on 2139c25 help sign in
unity8/Dash/Dash.qml
90 lines 2.8 kB history raw
1/*
2 * Copyright (C) 2013 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.0
18import Ubuntu.Components 0.1
19import Unity 0.1
20import Utils 0.1
21import "../Components"
23Showable {
24 id: dash
26 property alias contentProgress: dashContent.contentProgress
27 property string showScopeOnLoaded: "home.scope"
28 property real contentScale: 1.0
30 function setCurrentScope(scopeId, animate, reset) {
31 var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId)
33 if (scopeIndex == -1) {
34 console.warn("No match for scope with id: %1".arg(scopeId))
35 return
36 }
38 if (scopeIndex == dashContent.currentIndex && !reset) {
39 // the scope is already the current one
40 return
41 }
43 dashContent.setCurrentScopeAtIndex(scopeIndex, animate, reset)
44 }
46 SortFilterProxyModel {
47 id: filteredScopes
48 model: Scopes {
49 id: scopes
50 }
51 dynamicSortFilter: true
53 filterRole: Scopes.RoleVisible
54 filterRegExp: RegExp("^true$")
55 }
57 DashContent {
58 id: dashContent
59 objectName: "dashContent"
60 anchors.fill: parent
61 model: filteredScopes
62 scopes: scopes
63 onMovementStarted: dashbar.startNavigation()
64 onMovementEnded: dashbar.stopNavigation()
65 onContentFlickStarted: dashbar.finishNavigation()
66 onContentEndReached: dashbar.finishNavigation()
67 onPreviewShown: dashbar.finishNavigation()
68 onScopeLoaded: {
69 if (scopeId == dash.showScopeOnLoaded) {
70 dash.setCurrentScope(scopeId, false, false)
71 dash.showScopeOnLoaded = ""
72 }
73 }
74 scale: dash.contentScale
75 clip: scale != 1.0
76 }
78 DashBar {
79 id: dashbar
80 objectName: "dashbar"
81 anchors.bottom: parent.bottom
82 anchors.left: parent.left
83 anchors.right: parent.right
84 model: filteredScopes
85 currentIndex: dashContent.currentIndex
86 onItemSelected: dashContent.setCurrentScopeAtIndex(index, true, false)
87 opacity: dash.contentScale == 1.0 ? 1.0 : 0.0
88 Behavior on opacity { NumberAnimation { easing.type: Easing.OutQuad; duration: 150 } }
89 }