Unity 8
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 
17 import QtQuick 2.4
18 import QtQuick.Layouts 1.1
19 import Ubuntu.Components 1.3
20 import Unity.Indicators 0.1 as Indicators
21 import Utils 0.1
22 import "../Components"
23 import "Indicators"
24 
25 Rectangle {
26  id: content
27 
28  property QtObject indicatorsModel: null
29  property int currentMenuIndex: -1
30  color: "#221e1c" // FIXME not in palette yet
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.indicatorsModel
44 
45  highlightFollowsCurrentItem: true
46  interactive: false
47  highlightMoveDuration: 0
48  orientation: ListView.Horizontal
49  // Load all the indicator menus (a big number)
50  cacheBuffer: 1073741823
51 
52  // for additions/removals.
53  onCountChanged: {
54  listViewContent.currentIndex = content.currentMenuIndex;
55  }
56 
57  delegate: Loader {
58  id: loader
59 
60  width: ListView.view.width
61  height: ListView.view.height
62  objectName: identifier
63  asynchronous: true
64  visible: ListView.isCurrentItem
65 
66  sourceComponent: IndicatorPage {
67  objectName: identifier + "-page"
68 
69  identifier: model.identifier
70  busName: indicatorProperties.busName
71  actionsObjectPath: indicatorProperties.actionsObjectPath
72  menuObjectPath: indicatorProperties.menuObjectPath
73  }
74 
75  onVisibleChanged: {
76  // Reset the indicator states
77  if (!visible && status == Loader.Ready) {
78  item.reset();
79  }
80  }
81  }
82  }
83 }