on e375178 help sign in
unity8/Dash/Dash.qml
93 lines 2.9 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 width: units.gu(40)
31 height: units.gu(71)
33 function setCurrentScope(scopeId, animate, reset) {
34 var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId)
36 if (scopeIndex == -1) {
37 console.warn("No match for scope with id: %1".arg(scopeId))
38 return
39 }
41 if (scopeIndex == dashContent.currentIndex && !reset) {
42 // the scope is already the current one
43 return
44 }
46 dashContent.setCurrentScopeAtIndex(scopeIndex, animate, reset)
47 }
49 SortFilterProxyModel {
50 id: filteredScopes
51 model: Scopes {
52 id: scopes
53 }
54 dynamicSortFilter: true
56 filterRole: Scopes.RoleVisible
57 filterRegExp: RegExp("^true$")
58 }
60 DashContent {
61 id: dashContent
62 objectName: "dashContent"
63 anchors.fill: parent
64 model: filteredScopes
65 scopes: scopes
66 onMovementStarted: dashbar.startNavigation()
67 onMovementEnded: dashbar.stopNavigation()
68 onContentFlickStarted: dashbar.finishNavigation()
69 onContentEndReached: dashbar.finishNavigation()
70 onPreviewShown: dashbar.finishNavigation()
71 onScopeLoaded: {
72 if (scopeId == dash.showScopeOnLoaded) {
73 dash.setCurrentScope(scopeId, false, false)
74 dash.showScopeOnLoaded = ""
75 }
76 }
77 scale: dash.contentScale
78 clip: scale != 1.0
79 }
81 DashBar {
82 id: dashbar
83 objectName: "dashbar"
84 anchors.bottom: parent.bottom
85 anchors.left: parent.left
86 anchors.right: parent.right
87 model: filteredScopes
88 currentIndex: dashContent.currentIndex
89 onItemSelected: dashContent.setCurrentScopeAtIndex(index, true, false)
90 opacity: dash.contentScale == 1.0 ? 1.0 : 0.0
91 Behavior on opacity { NumberAnimation { easing.type: Easing.OutQuad; duration: 150 } }
92 }