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