on xenial help sign in
Indicator menus using tabs.
commit7acf41522333768789ef114c049ba2a90bcbf164 authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 17 Jul 2013, 17:30 (13 years ago) parentbf91bc9
3 files changed+137−12
Panel/Indicators.qml+1−1 Panel/Indicators/NetworkIndicatorPage.qml+14−11 Panel/MenuContentTabs.qml+122
Panel/Indicators.qml+1−1
@@ -164,7 +164,7 @@ Showable {
164164 source: "graphics/VerticalDivider.png"
165165 }
166166
167− MenuContent {
167+ MenuContentTabs {
168168 id: menuContent
169169 objectName: "menuContent"
170170
Panel/Indicators/NetworkIndicatorPage.qml+14−11
@@ -23,23 +23,26 @@ import Unity.Indicators.Network 0.1 as ICNetwork
2323import Ubuntu.Components 0.1
2424
2525PageStack {
26− id: _network
26+ id: network
27+ // Stops the search for a parent tree node.
28+ // We don't want it going up to the indicator tabs.
29+ // FIXME: need a better way of doing this.
30+ __propagated: null
2731
2832 property alias title: _mainPage.title
29− property alias emptyText: _pluginItem.emptyText
30− property alias busType: _pluginItem.busType
31− property alias busName: _pluginItem.busName
32− property alias actionsObjectPath : _pluginItem.actionsObjectPath
33− property alias menuObjectPaths : _pluginItem.menuObjectPaths
33+ property alias emptyText: pluginItem.emptyText
34+ property alias busType: pluginItem.busType
35+ property alias busName: pluginItem.busName
36+ property alias actionsObjectPath : pluginItem.actionsObjectPath
37+ property alias menuObjectPaths : pluginItem.menuObjectPaths
3438
35− __showHeader: false
3639 anchors.fill: parent
3740
3841 Page {
3942 id: _mainPage
4043
4144 Indicators.IndicatorPage {
42− id: _pluginItem
45+ id: pluginItem
4346 anchors.fill: parent
4447 }
4548 }
@@ -63,17 +66,17 @@ PageStack {
6366 function start()
6467 {
6568 push(_mainPage);
66− _pluginItem.start();
69+ pluginItem.start();
6770 }
6871
6972 function stop()
7073 {
7174 clear();
72− _pluginItem.stop();
75+ pluginItem.stop();
7376 }
7477
7578 function reset()
7679 {
77− _pluginItem.reset();
80+ pluginItem.reset();
7881 }
7982}
Panel/MenuContentTabs.qmlnew file+122
@@ -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+}