on xenial help sign in
Indicator menus using tabs.
7acf415Nick Dedekind
Panel/Indicators.qml+1−1
@@ -164,7 +164,7 @@ Showable {
164 source: "graphics/VerticalDivider.png"
164 source: "graphics/VerticalDivider.png"
165 }
165 }
166
166
167− MenuContent {
167+ MenuContentTabs {
168 id: menuContent
168 id: menuContent
169 objectName: "menuContent"
169 objectName: "menuContent"
170
170
Panel/Indicators/NetworkIndicatorPage.qml+14−11
@@ -23,23 +23,26 @@ import Unity.Indicators.Network 0.1 as ICNetwork
23import Ubuntu.Components 0.1
23import Ubuntu.Components 0.1
24
24
25PageStack {
25PageStack {
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
27
31
28 property alias title: _mainPage.title
32 property alias title: _mainPage.title
29− property alias emptyText: _pluginItem.emptyText
33+ property alias emptyText: pluginItem.emptyText
30− property alias busType: _pluginItem.busType
34+ property alias busType: pluginItem.busType
31− property alias busName: _pluginItem.busName
35+ property alias busName: pluginItem.busName
32− property alias actionsObjectPath : _pluginItem.actionsObjectPath
36+ property alias actionsObjectPath : pluginItem.actionsObjectPath
33− property alias menuObjectPaths : _pluginItem.menuObjectPaths
37+ property alias menuObjectPaths : pluginItem.menuObjectPaths
34
38
35− __showHeader: false
36 anchors.fill: parent
39 anchors.fill: parent
37
40
38 Page {
41 Page {
39 id: _mainPage
42 id: _mainPage
40
43
41 Indicators.IndicatorPage {
44 Indicators.IndicatorPage {
42− id: _pluginItem
45+ id: pluginItem
43 anchors.fill: parent
46 anchors.fill: parent
44 }
47 }
45 }
48 }
@@ -63,17 +66,17 @@ PageStack {
63 function start()
66 function start()
64 {
67 {
65 push(_mainPage);
68 push(_mainPage);
66− _pluginItem.start();
69+ pluginItem.start();
67 }
70 }
68
71
69 function stop()
72 function stop()
70 {
73 {
71 clear();
74 clear();
72− _pluginItem.stop();
75+ pluginItem.stop();
73 }
76 }
74
77
75 function reset()
78 function reset()
76 {
79 {
77− _pluginItem.reset();
80+ pluginItem.reset();
78 }
81 }
79}
82}
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+}