on bbbdccd help sign in
unity8/qml/Dash/DashNavigationList.qml
167 lines 5.9 kB history raw
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 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19import Ubuntu.Components.ListItems 1.3 as ListItem
20import "../Components"
22Item {
23 id: root
24 property var navigation: null
25 property var currentNavigation: null
26 property var scopeStyle: null
27 property color foregroundColor: theme.palette.normal.baseText
28 signal enterNavigation(var newNavigationId, bool hasChildren)
29 signal goBackToParentClicked()
30 signal allNavigationClicked()
32 readonly property int itemHeight: units.gu(5)
33 implicitHeight: flickable.contentHeight
35 Background {
36 style: root.scopeStyle ? root.scopeStyle.navigationBackground : "color:///#f5f5f5"
37 anchors.fill: parent
38 }
40 clip: true
42 Behavior on height {
43 UbuntuNumberAnimation {
44 id: heightAnimation
45 duration: UbuntuAnimation.SnapDuration
46 }
47 }
49 Flickable {
50 id: flickable
52 anchors.fill: parent
54 flickableDirection: Flickable.VerticalFlick
55 contentHeight: column.height
56 contentWidth: width
58 Column {
59 id: column
60 width: parent.width
62 ListItem.Standard {
63 id: backButton
64 objectName: "backButton"
65 visible: navigation && !navigation.isRoot || false
66 height: itemHeight
68 onClicked: root.goBackToParentClicked();
70 Icon {
71 id: backImage
72 anchors {
73 verticalCenter: parent.verticalCenter
74 left: parent.left
75 leftMargin: units.gu(2)
76 }
77 name: "back"
78 height: units.gu(2)
79 width: height
80 color: root.foregroundColor
81 }
83 Label {
84 anchors {
85 verticalCenter: parent.verticalCenter
86 left: backImage.right
87 right: parent.right
88 leftMargin: units.gu(0.5)
89 rightMargin: units.gu(2)
90 }
91 text: navigation ? navigation.parentLabel : ""
92 color: root.foregroundColor
93 wrapMode: Text.Wrap
94 maximumLineCount: 2
95 elide: Text.ElideMiddle
96 }
97 }
99 ListItem.Standard {
100 id: allButton
101 objectName: "allButton"
102 visible: navigation && (!navigation.isRoot || (!navigation.hidden && root.currentNavigation && !root.currentNavigation.isRoot && root.currentNavigation.parentNavigationId == navigation.navigationId)) || false
103 height: itemHeight
105 Label {
106 anchors {
107 verticalCenter: parent.verticalCenter
108 left: parent.left
109 right: parent.right
110 leftMargin: units.gu(2)
111 rightMargin: units.gu(2)
112 }
113 text: navigation ? (navigation.allLabel != "" ? navigation.allLabel : navigation.label) : ""
114 font.bold: true
115 color: root.foregroundColor
116 wrapMode: Text.Wrap
117 maximumLineCount: 2
118 elide: Text.ElideMiddle
119 }
121 onClicked: root.allNavigationClicked();
122 }
124 Repeater {
125 model: navigation && navigation.loaded ? navigation : null
126 clip: true
127 delegate: ListItem.Standard {
128 objectName: root.objectName + "child" + index
129 height: root.itemHeight
130 showDivider: index != navigation.count - 1
131 selected: isActive
133 onClicked: root.enterNavigation(navigationId, hasChildren)
135 Label {
136 anchors {
137 verticalCenter: parent.verticalCenter
138 left: parent.left
139 leftMargin: units.gu(2)
140 right: rightIcon.visible ? rightIcon.left : parent.right
141 rightMargin: rightIcon.visible ? units.gu(0.5) : units.gu(2)
142 }
143 text: label
144 color: root.foregroundColor
145 wrapMode: Text.Wrap
146 maximumLineCount: 2
147 elide: Text.ElideMiddle
148 }
150 Icon {
151 id: rightIcon
152 anchors {
153 verticalCenter: parent.verticalCenter
154 right: parent.right
155 rightMargin: units.gu(2)
156 }
157 height: units.gu(2)
158 width: height
159 name: hasChildren ? "go-next" : "tick"
160 color: root.foregroundColor
161 visible: hasChildren || isActive
162 }
163 }
164 }
165 }
166 }