on 6231502 help sign in
unity8/qml/Panel/MenuContent.qml
133 lines 4.0 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 QtQuick.Layouts 1.1
19import Ubuntu.Components 1.1
20import Unity.Indicators 0.1 as Indicators
21import Utils 0.1
22import "../Components"
23import "Indicators"
25Rectangle {
26 id: content
28 property QtObject indicatorsModel: null
29 readonly property alias currentMenuIndex: listViewHeader.currentIndex
30 color: "#221e1c" // FIXME not in palette yet
31 property real headerHeight: listViewHeader.height
33 width: units.gu(40)
34 height: units.gu(42)
36 function setCurrentMenuIndex(index, animate) {
37 // FIXME - https://bugreports.qt-project.org/browse/QTBUG-41229
38 listViewHeader.currentIndex = -1;
39 listViewHeader.currentIndex = index;
40 }
42 ListView {
43 id: listViewHeader
44 objectName: "indicatorsHeaderListView"
45 model: content.indicatorsModel
46 clip: true
48 anchors {
49 left: parent.left
50 right: parent.right
51 }
52 height: units.gu(8.5)
54 highlightFollowsCurrentItem: true
55 highlightMoveDuration: 0
57 orientation: ListView.Horizontal
58 snapMode: ListView.SnapOneItem
59 highlightRangeMode: ListView.StrictlyEnforceRange
60 boundsBehavior: Flickable.StopAtBounds
61 // Load all the indicator menus (a big number)
62 cacheBuffer: 1073741823
64 delegate: Header {
65 width: ListView.view.width
66 height: implicitHeight
68 title: indicatorDelegate.title !== "" ? indicatorDelegate.title : identifier
70 IndicatorDelegate {
71 id: indicatorDelegate
72 Component.onCompleted: {
73 for(var pName in indicatorProperties) {
74 if (indicatorDelegate.hasOwnProperty(pName)) {
75 indicatorDelegate[pName] = indicatorProperties[pName];
76 }
77 }
78 }
79 }
80 }
81 }
83 ListView {
84 id: listViewContent
85 objectName: "indicatorsContentListView"
86 anchors {
87 left: parent.left
88 right: parent.right
89 top: listViewHeader.bottom
90 bottom: parent.bottom
91 }
92 model: content.indicatorsModel
93 clip: true
95 currentIndex: listViewHeader.currentIndex
96 interactive: false
97 highlightMoveDuration: 0
98 orientation: ListView.Horizontal
99 // Load all the indicator menus (a big number)
100 cacheBuffer: 1073741823
102 delegate: Loader {
103 id: loader
104 width: ListView.view.width
105 height: ListView.view.height
106 objectName: identifier
108 source: pageSource
109 asynchronous: true
111 onVisibleChanged: {
112 // Reset the indicator states
113 if (!visible && item && item["reset"]) {
114 item.reset()
115 }
116 }
118 onLoaded: {
119 for(var pName in indicatorProperties) {
120 if (item.hasOwnProperty(pName)) {
121 item[pName] = indicatorProperties[pName]
122 }
123 }
124 }
126 Binding {
127 target: loader.item
128 property: "objectName"
129 value: identifier + "-page"
130 }
131 }
132 }