2 * Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
18 import Ubuntu.Components 0.1
19 import Unity.Indicators 0.1 as Indicators
21 import "../Components"
23 // FIXME : We dont want to use MainView.
24 // Need a regular Item which can have tabs with local header.
25 // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1211704
29 property QtObject indicatorsModel: null
30 property bool __contentActive: false
31 readonly property int currentMenuIndex: tabs.selectedTabIndex
32 backgroundColor: "#221e1c" // FIXME not in palette yet
33 property int contentReleaseInterval: 20000
34 property bool activeHeader: false
35 property real headerHeight: tabs.tabBar.height
40 function setCurrentMenuIndex(index, animate) {
41 if (tabs.selectedTabIndex !== index) {
42 if (tabs.selectedTabIndex === -1 || !animate) {
43 tabs.tabBar.animate = false;
45 tabs.selectedTabIndex = index;
46 tabs.tabBar.animate = true;
50 function activateContent() {
51 contentReleaseTimer.stop();
52 __contentActive = true;
55 function releaseContent() {
56 if (__contentActive) {
57 contentReleaseTimer.restart();
61 onActiveHeaderChanged: {
62 tabs.tabBar.selectionMode = activeHeader;
63 tabs.tabBar.alwaysSelectionMode = activeHeader;
73 model: content.indicatorsModel ? content.indicatorsModel : null
74 objectName: "tabsRepeater"
76 // FIXME: This is needed because tabs dont handle repeaters well.
77 // Due to the child ordering happening after child insertion.
80 parent.childrenChanged();
85 objectName: model.identifier
95 readonly property bool indexActive: index >= 0 && index < menuActivator.count && menuActivator.content[index].active
96 readonly property bool contentActive: content.__contentActive && indexActive
98 onContentActiveChanged: {
99 if (contentActive && item) {
101 } else if (!contentActive && item) {
107 // Reset the indicator states
108 if (!visible && item && item["reset"]) {
114 for(var pName in indicatorProperties) {
115 if (item.hasOwnProperty(pName)) {
116 item[pName] = indicatorProperties[pName]
119 if (contentActive && tabs.visible) {
127 value: loader.item && loader.item.hasOwnProperty("title") && loader.item.title !== "" ? loader.item.title : model.identifier
132 property: "objectName"
133 value: identifier + "-page"
142 id: contentReleaseTimer
144 interval: contentReleaseInterval
146 content.__contentActive = false;
147 menuActivator.clear();
151 Indicators.MenuContentActivator {
153 running: content.__contentActive
154 baseIndex: content.currentMenuIndex
155 count: indicatorsModel.count