on e268fff help sign in
unity8/qml/Panel/MenuContent.qml
140 lines 4.2 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 "../Components/Flickables" as Flickables
24import "Indicators"
26Rectangle {
27 id: content
29 property QtObject indicatorsModel: null
30 readonly property alias currentMenuIndex: listViewHeader.currentIndex
31 color: "#221e1c" // FIXME not in palette yet
32 property real headerHeight: listViewHeader.height
34 width: units.gu(40)
35 height: units.gu(42)
37 function setCurrentMenuIndex(index, animate) {
38 // FIXME - https://bugreports.qt-project.org/browse/QTBUG-41229
39 listViewHeader.currentIndex = -1;
40 listViewHeader.currentIndex = index;
41 }
43 Flickables.ListView {
44 id: listViewHeader
45 objectName: "indicatorsHeaderListView"
46 model: content.indicatorsModel
47 clip: true
49 anchors {
50 left: parent.left
51 right: parent.right
52 }
53 height: units.gu(8.5)
55 highlightFollowsCurrentItem: true
56 highlightMoveDuration: 0
58 orientation: ListView.Horizontal
59 snapMode: ListView.SnapOneItem
60 highlightRangeMode: ListView.StrictlyEnforceRange
61 boundsBehavior: Flickable.StopAtBounds
62 // Load all the indicator menus (a big number)
63 cacheBuffer: 1073741823
65 delegate: Header {
66 width: ListView.view.width
67 height: implicitHeight
69 title: indicatorDelegate.title !== "" ? indicatorDelegate.title : identifier
71 IndicatorDelegate {
72 id: indicatorDelegate
73 Component.onCompleted: {
74 for(var pName in indicatorProperties) {
75 if (indicatorDelegate.hasOwnProperty(pName)) {
76 indicatorDelegate[pName] = indicatorProperties[pName];
77 }
78 }
79 }
80 }
81 }
82 }
84 Flickables.ListView {
85 id: listViewContent
86 objectName: "indicatorsContentListView"
87 anchors {
88 left: parent.left
89 right: parent.right
90 top: listViewHeader.bottom
91 bottom: parent.bottom
92 }
93 model: content.indicatorsModel
94 clip: true
96 currentIndex: listViewHeader.currentIndex
97 interactive: false
98 highlightMoveDuration: 0
99 orientation: ListView.Horizontal
100 // Load all the indicator menus (a big number)
101 cacheBuffer: 1073741823
103 delegate: Loader {
104 id: loader
105 width: ListView.view.width
106 height: ListView.view.height
107 objectName: identifier
109 source: pageSource
110 asynchronous: true
112 onVisibleChanged: {
113 // Reset the indicator states
114 if (!visible && item && item["reset"]) {
115 item.reset()
116 }
117 }
119 onLoaded: {
120 for(var pName in indicatorProperties) {
121 if (item.hasOwnProperty(pName)) {
122 item[pName] = indicatorProperties[pName]
123 }
124 }
125 }
127 Binding {
128 target: loader.item
129 property: "identifier"
130 value: identifier
131 }
133 Binding {
134 target: loader.item
135 property: "objectName"
136 value: identifier + "-page"
137 }
138 }
139 }