Lomiri
Loading...
Searching...
No Matches
MenuContent.qml
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 */
16
17import QtQuick 2.12
18import QtQuick.Layouts 1.1
19import Lomiri.Components 1.3
20import Lomiri.Indicators 0.1 as Indicators
21import Utils 0.1
22import "../Components"
23import "Indicators"
24
25Item {
26 id: content
27
28 property QtObject model: null
29 property int currentMenuIndex: -1
30 property Component pageDelegate
31
32 width: units.gu(40)
33 height: units.gu(42)
34
35 onCurrentMenuIndexChanged: {
36 listViewContent.currentIndex = currentMenuIndex;
37 }
38
39 ListView {
40 id: listViewContent
41 objectName: "indicatorsContentListView"
42 anchors.fill: parent
43 model: content.model
44
45 highlightFollowsCurrentItem: false
46 interactive: false
47 orientation: ListView.Horizontal
48 // Load all the indicator menus (a big number)
49 cacheBuffer: 1073741823
50
51 // for additions/removals.
52 onCountChanged: {
53 listViewContent.currentIndex = content.currentMenuIndex;
54 }
55
56 onCurrentIndexChanged: {
57 positionViewAtIndex(currentIndex, ListView.Beginning);
58 }
59
60 delegate: Loader {
61 id: loader
62
63 width: ListView.view.width
64 height: ListView.view.height
65 asynchronous: true
66 visible: ListView.isCurrentItem
67
68 property var modelData: model
69 property var modelIndex: index
70
71 sourceComponent: pageDelegate
72
73 onVisibleChanged: {
74 // Reset the indicator states
75 if (!visible && status == Loader.Ready) {
76 item.reset();
77 }
78 }
79 }
80 }
81}