on 8cb81fa help sign in
unity8/qml/Panel/MenuContent.qml
80 lines 2.2 kB history raw
1/*
2 * Copyright (C) 2013-2014 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 QtQuick.Layouts 1.1
19import Ubuntu.Components 1.3
20import Unity.Indicators 0.1 as Indicators
21import Utils 0.1
22import "../Components"
23import "Indicators"
25Rectangle {
26 id: content
28 property QtObject model: null
29 property int currentMenuIndex: -1
30 property Component pageDelegate
32 color: theme.palette.normal.background
34 width: units.gu(40)
35 height: units.gu(42)
37 onCurrentMenuIndexChanged: {
38 listViewContent.currentIndex = currentMenuIndex;
39 }
41 ListView {
42 id: listViewContent
43 objectName: "indicatorsContentListView"
44 anchors.fill: parent
45 model: content.model
47 highlightFollowsCurrentItem: false
48 contentX: currentIndex * width
49 interactive: false
50 orientation: ListView.Horizontal
51 // Load all the indicator menus (a big number)
52 cacheBuffer: 1073741823
54 // for additions/removals.
55 onCountChanged: {
56 listViewContent.currentIndex = content.currentMenuIndex;
57 }
59 delegate: Loader {
60 id: loader
62 width: ListView.view.width
63 height: ListView.view.height
64 asynchronous: true
65 visible: ListView.isCurrentItem
67 property var modelData: model
68 property var modelIndex: index
70 sourceComponent: pageDelegate
72 onVisibleChanged: {
73 // Reset the indicator states
74 if (!visible && status == Loader.Ready) {
75 item.reset();
76 }
77 }
78 }
79 }