on 96bb7e5 help sign in
unity8/tests/mocks/Unity/Indicators/IndicatorsModel.qml
176 lines 7.9 kB history raw
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 */
17import QtQuick 2.0
18import Unity.Indicators 0.1 as Indicators
20Indicators.FakeIndicatorsModel {
21 id: root
23 Component.onCompleted: {
24 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake1",
25 "/com/canonical/indicators/fake1",
26 "/com/canonical/indicators/fake1",
27 {
28 "title": "Bluetooth (F)",
29 "icons": [ "image://theme/bluetooth-active" ],
30 },
31 getUnityMenuModelData("fake-indicator-bluetooth"));
32 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake2",
33 "/com/canonical/indicators/fake2",
34 "/com/canonical/indicators/fake2",
35 {
36 "title": "Network (F)",
37 "icons": [ "image://theme/simcard-error", "image://theme/wifi-high" ],
38 },
39 getUnityMenuModelData("fake-indicator-network"));
40 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake3",
41 "/com/canonical/indicators/fake3",
42 "/com/canonical/indicators/fake3",
43 {
44 "title": "Messages (F)",
45 "icons": [ "image://theme/messages-new" ],
46 },
47 getUnityMenuModelData("fake-indicator-sound"));
48 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake4",
49 "/com/canonical/indicators/fake4",
50 "/com/canonical/indicators/fake4",
51 {
52 "title": "Sound (F)",
53 "icons": [ "image://theme/audio-volume-high" ],
54 },
55 getUnityMenuModelData("fake-indicator-power"));
56 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake5",
57 "/com/canonical/indicators/fake5",
58 "/com/canonical/indicators/fake5",
59 {
60 "title": "Battery (F)",
61 "icons": [ "image://theme/battery-020" ],
62 },
63 getUnityMenuModelData("fake-indicator-bluetooth"));
64 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake6",
65 "/com/canonical/indicators/fake6",
66 "/com/canonical/indicators/fake6",
67 {
68 "title": "Upcoming Events (F)",
69 "label": "12:04",
70 },
71 getUnityMenuModelData("fake-indicator-datetime"));
72 }
74 function getUnityMenuModelData(identifier) {
75 var root = [{
76 "rowData": { // 1
77 "label": "root",
78 "sensitive": true,
79 "isSeparator": false,
80 "icon": "",
81 "type": "com.canonical.indicator.root",
82 "ext": {},
83 "action": "",
84 "actionState": {},
85 "isCheck": false,
86 "isRadio": false,
87 "isToggled": false,
88 },
89 "submenu": []
90 }];
92 var submenus = [];
93 for (var i = 0; i < 8; i++) {
94 var submenu = {
95 "rowData": { // 1.1
96 "label": identifier,
97 "sensitive": true,
98 "isSeparator": false,
99 "icon": "",
100 "type": undefined,
101 "ext": {},
102 "action": "",
103 "actionState": {},
104 "isCheck": false,
105 "isRadio": false,
106 "isToggled": false,
107 }};
108 submenus.push(submenu);
109 }
110 root[0]["submenu"] = submenus;
112 return root;
113 }
115 property var originalModelData: [
116 {
117 "identifier": "fake-indicator-bluetooth",
118 "indicatorProperties": {
119 "enabled": true,
120 "busName": "com.canonical.indicators.fake1",
121 "menuObjectPath": "/com/canonical/indicators/fake1",
122 "actionsObjectPath": "/com/canonical/indicators/fake1"
123 }
124 },
125 {
126 "identifier": "fake-indicator-network",
127 "indicatorProperties": {
128 "enabled": true,
129 "busName": "com.canonical.indicators.fake2",
130 "menuObjectPath": "/com/canonical/indicators/fake2",
131 "actionsObjectPath": "/com/canonical/indicators/fake2"
132 }
133 },
134 {
135 "identifier": "fake-indicator-messages",
136 "indicatorProperties": {
137 "enabled": true,
138 "busName": "com.canonical.indicators.fake3",
139 "menuObjectPath": "/com/canonical/indicators/fake3",
140 "actionsObjectPath": "/com/canonical/indicators/fake3"
141 }
142 },
143 {
144 "identifier": "fake-indicator-sound",
145 "indicatorProperties": {
146 "enabled": true,
147 "busName": "com.canonical.indicators.fake4",
148 "menuObjectPath": "/com/canonical/indicators/fake4",
149 "actionsObjectPath": "/com/canonical/indicators/fake4"
150 }
151 },
152 {
153 "identifier": "fake-indicator-power",
154 "indicatorProperties": {
155 "enabled": true,
156 "busName": "com.canonical.indicators.fake5",
157 "menuObjectPath": "/com/canonical/indicators/fake5",
158 "actionsObjectPath": "/com/canonical/indicators/fake5"
159 }
160 },
161 {
162 "identifier": "fake-indicator-datetime",
163 "indicatorProperties": {
164 "enabled": true,
165 "busName": "com.canonical.indicators.fake6",
166 "menuObjectPath": "/com/canonical/indicators/fake6",
167 "actionsObjectPath": "/com/canonical/indicators/fake6"
168 }
169 }
170 ]
172 function load(profile) {
173 unload();
174 root.modelData = originalModelData;
175 }