@@ -0,0 +1,122 @@
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+ */
16+
17+import QtQuick 2.0
18+import Ubuntu.Components 0.1
19+import Unity.Indicators 0.1 as Indicators
20+import "../Components"
21+
22+MainView {
23+ id: content
24+
25+ property QtObject indicatorsModel: null
26+ property alias currentMenuIndex : tabs.selectedTabIndex
27+ property color backgroundColor: "#221e1c"
28+ property int contentReleaseInterval: 20000
29+
30+ width: units.gu(40)
31+ height: units.gu(42)
32+
33+ // FIXME: *grumble* MainView is locked to style with a background. OVERRIDE!!
34+ Rectangle {
35+ anchors.fill: parent
36+ color: backgroundColor
37+ }
38+
39+ QtObject {
40+ id: d
41+ property bool contentActive: false
42+ }
43+
44+ function activateContent() {
45+ contentReleaseTimer.stop();
46+ d.contentActive = true;
47+ }
48+
49+ function releaseContent() {
50+ if (d.contentActive) {
51+ contentReleaseTimer.restart();
52+ }
53+ }
54+
55+ Tabs {
56+ id: tabs
57+ anchors.fill: parent
58+ selectedTabIndex: -1
59+
60+ Repeater {
61+ id: repeater
62+ model: indicatorsModel
63+ objectName: "menus"
64+
65+ // FIXME: This is needed because tabs dont handle repeaters well.
66+ // Due to the child ordering happening after child insertion.
67+ // QTBUG-32438
68+ onItemAdded: {
69+ parent.childrenChanged();
70+ }
71+
72+ Tab {
73+ id: tab
74+ title: indicatorsModel ? indicatorsModel.data(index, Indicators.IndicatorsModelRole.Title) : ""
75+
76+ page: Page {
77+ Loader {
78+ clip: true
79+ anchors.fill: parent
80+ source: pageSource
81+ asynchronous: true
82+
83+ property bool contentActive: d.contentActive
84+
85+ onContentActiveChanged: {
86+ if (contentActive && item) {
87+ item.start()
88+ } else if (!contentActive && item) {
89+ item.stop()
90+ }
91+ }
92+
93+ onVisibleChanged: {
94+ // Reset the indicator states
95+ if (!visible && item && item["reset"]) {
96+ item.reset()
97+ }
98+ }
99+
100+ onLoaded: {
101+ for(var pName in indicatorProperties) {
102+ if (item.hasOwnProperty(pName)) {
103+ item[pName] = indicatorProperties[pName]
104+ }
105+ }
106+ if (contentActive && menus.visible) {
107+ item.start()
108+ }
109+ }
110+ }
111+ }
112+ }
113+ }
114+ }
115+
116+ Timer {
117+ id: contentReleaseTimer
118+
119+ interval: contentReleaseInterval
120+ onTriggered: d.contentActive = false
121+ }
122+}