on xenial help sign in
MenuItemFactory: use more features from SlotsLayout based settings components
e7bed11Marco Trevisan (Treviño)
debian/control+1−1
@@ -65,7 +65,7 @@ Build-Depends: cmake,
65 qtdeclarative5-dev-tools,
65 qtdeclarative5-dev-tools,
66 qtdeclarative5-private-dev (>= 5.4),
66 qtdeclarative5-private-dev (>= 5.4),
67 qtdeclarative5-ubuntu-content1,
67 qtdeclarative5-ubuntu-content1,
68− qtdeclarative5-ubuntu-settings-components (>= 0.7),
68+ qtdeclarative5-ubuntu-settings-components (>= 0.10),
69 ttf-ubuntu-font-family,
69 ttf-ubuntu-font-family,
70Standards-Version: 3.9.4
70Standards-Version: 3.9.4
71Homepage: http://launchpad.net/unity
71Homepage: http://launchpad.net/unity
qml/Panel/Indicators/MenuItemFactory.qml+98−146
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013,2015 Canonical Ltd.
2+ * Copyright 2013-2016 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -31,7 +31,8 @@ Item {
31 property var rootModel: null
31 property var rootModel: null
32 property var menuModel: null
32 property var menuModel: null
33
33
34− property var _map: {
34+ property var _userMap: null
35+ readonly property var _typeToComponent: {
35 "default": {
36 "default": {
36 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
37 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
37 "unity.widgets.systemsettings.tablet.switch" : switchMenu,
38 "unity.widgets.systemsettings.tablet.switch" : switchMenu,
@@ -69,11 +70,62 @@ Item {
69 "indicator.guest-menu-item": Platform.isPC ? userMenuItem : null,
70 "indicator.guest-menu-item": Platform.isPC ? userMenuItem : null,
70 "com.canonical.indicator.switch": Math.min(Screen.width, Screen.height) > units.gu(60) ? switchMenu : null // Desktop mode switch
71 "com.canonical.indicator.switch": Math.min(Screen.width, Screen.height) > units.gu(60) ? switchMenu : null // Desktop mode switch
71 },
72 },
72− "indicator-messages" : {
73+ "indicator-messages": {
73− "com.canonical.indicator.button" : messagesButtonMenu
74+ "com.canonical.indicator.button": messagesButtonMenu
74 }
75 }
75 }
76 }
76
77
78+ readonly property var _action_filter_map: {
79+ "indicator-session": {
80+ "indicator.logout": Platform.isPC ? undefined : null,
81+ "indicator.suspend": Platform.isPC ? undefined : null,
82+ "indicator.hibernate": Platform.isPC ? undefined : null,
83+ "indicator.reboot": Platform.isPC ? undefined : null
84+ },
85+ "indicator-keyboard": {
86+ "indicator.map": null,
87+ "indicator.chart": null
88+ }
89+ }
90+
91+ function getComponentForIndicatorEntryType(indicator, type) {
92+ var component = undefined;
93+ var map = _userMap || _typeToComponent
94+ var indicatorComponents = map[indicator];
95+
96+ if (type === undefined || type === "") {
97+ return component
98+ }
99+
100+ if (indicatorComponents !== undefined) {
101+ component = indicatorComponents[type];
102+ }
103+
104+ if (component === undefined) {
105+ component = map["default"][type];
106+ }
107+
108+ if (component === undefined) {
109+ console.debug("Don't know how to make " + modelData.type + " for " + indicator);
110+ }
111+
112+ return component
113+ }
114+
115+ function getComponentForIndicatorEntryAction(indicator, action) {
116+ var component = undefined;
117+ var indicatorFilter = _action_filter_map[indicator]
118+
119+ if (action === undefined || action === "") {
120+ return component
121+ }
122+
123+ if (indicatorFilter !== undefined) {
124+ component = indicatorFilter[action];
125+ }
126+ return component
127+ }
128+
77 function getExtendedProperty(object, propertyName, defaultValue) {
129 function getExtendedProperty(object, propertyName, defaultValue) {
78 if (object && object.hasOwnProperty(propertyName)) {
130 if (object && object.hasOwnProperty(propertyName)) {
79 return object[propertyName];
131 return object[propertyName];
@@ -102,7 +154,6 @@ Item {
102 property var serverValue: getExtendedProperty(menuData, "actionState", undefined)
154 property var serverValue: getExtendedProperty(menuData, "actionState", undefined)
103
155
104 text: menuData && menuData.label || ""
156 text: menuData && menuData.label || ""
105− iconSource: menuData && menuData.icon || ""
106 minIcon: getExtendedProperty(extendedData, "minIcon", "")
157 minIcon: getExtendedProperty(extendedData, "minIcon", "")
107 maxIcon: getExtendedProperty(extendedData, "maxIcon", "")
158 maxIcon: getExtendedProperty(extendedData, "maxIcon", "")
108
159
@@ -182,29 +233,20 @@ Item {
182 Component {
233 Component {
183 id: messagesButtonMenu;
234 id: messagesButtonMenu;
184
235
185− Item {
236+ Menus.BaseLayoutMenu {
186 objectName: "messagesButtonMenu"
237 objectName: "messagesButtonMenu"
187 property QtObject menuData: null
238 property QtObject menuData: null
188 property var menuModel: menuFactory.menuModel
239 property var menuModel: menuFactory.menuModel
189 property int menuIndex: -1
240 property int menuIndex: -1
190
241
191− implicitHeight: units.gu(5)
242+ highlightWhenPressed: false
192 enabled: menuData && menuData.sensitive || false
243 enabled: menuData && menuData.sensitive || false
244+ text: menuData && menuData.label || ""
245+ title.color: theme.palette.selected.backgroundText
246+ title.horizontalAlignment: Text.AlignHCenter
247+ title.font.bold: true
193
248
194− Label {
195− id: buttonMenuLabel
196− text: menuData && menuData.label || ""
197− anchors.centerIn: parent
198− font.bold: true
199− }
200−
201− MouseArea {
202− anchors {
203− fill: buttonMenuLabel
204− margins: units.gu(-1)
205− }
206− onClicked: menuModel.activate(menuIndex);
249+ onClicked: menuModel.activate(menuIndex);
207− }
208 }
250 }
209 }
251 }
210
252
@@ -233,11 +275,6 @@ Item {
233 iconSource: menuData && menuData.icon || ""
275 iconSource: menuData && menuData.icon || ""
234 value : menuData && menuData.actionState || 0.0
276 value : menuData && menuData.actionState || 0.0
235 enabled: menuData && menuData.sensitive || false
277 enabled: menuData && menuData.sensitive || false
236− // FIXME: Because of this bug, setting it to the theme foreground color (white)
237− // currently doesn't work. Let's hack it to be "close enough"
238− // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1555784
239− foregroundColor: "#fffffe"
240− highlightWhenPressed: false
241 }
278 }
242 }
279 }
243
280
@@ -257,52 +294,41 @@ Item {
257 onTriggered: {
294 onTriggered: {
258 menuModel.activate(menuIndex);
295 menuModel.activate(menuIndex);
259 }
296 }
260−
261− // FIXME : At the moment, the indicators aren't using
262− // com.canonical.indicators.link for settings menu. Need to fudge it.
263− property bool settingsMenu: menuData && menuData.action.indexOf("settings") > -1 || false
264− backColor: settingsMenu ? Qt.rgba(1,1,1,0.07) : "transparent"
265− component: settingsMenu ? buttonForSettings : undefined
266− Component {
267− id: buttonForSettings
268− Icon {
269− name: "settings"
270− height: units.gu(3)
271− width: height
272− color: theme.palette.normal.backgroundText
273− }
274− }
275 }
297 }
276 }
298 }
277
299
278 Component {
300 Component {
279 id: linkMenu;
301 id: linkMenu;
280
302
281− Menus.StandardMenu {
303+ Menus.BaseLayoutMenu {
282 objectName: "linkMenu"
304 objectName: "linkMenu"
283 property QtObject menuData: null
305 property QtObject menuData: null
284 property int menuIndex: -1
306 property int menuIndex: -1
285
307
286 text: menuData && menuData.label || ""
308 text: menuData && menuData.label || ""
287− iconSource: menuData && menuData.icon || ""
288 enabled: menuData && menuData.sensitive || false
309 enabled: menuData && menuData.sensitive || false
310+ backColor: Qt.rgba(1,1,1,0.07)
289 highlightWhenPressed: false
311 highlightWhenPressed: false
290
312
291 onTriggered: {
313 onTriggered: {
292 menuModel.activate(menuIndex);
314 menuModel.activate(menuIndex);
293 }
315 }
294
316
295− backColor: Qt.rgba(1,1,1,0.07)
296−
297− component: menuData.icon ? icon : undefined
298− Component {
299− id: icon
300− Icon {
317+ slots: Icon {
318+ source: {
319+ if (menuData) {
301− source: menuData.icon
320+ if (menuData.icon && menuData.icon != "") {
302− height: units.gu(3)
321+ return menuData.icon
303− width: height
322+ } else if (menuData.action.indexOf("settings") > -1) {
304− color: theme.palette.normal.backgroundText
323+ return "image://theme/settings"
324+ }
325+ }
326+ return ""
305 }
327 }
328+ height: units.gu(3)
329+ width: height
330+ color: theme.palette.normal.backgroundText
331+ SlotsLayout.position: SlotsLayout.Trailing
306 }
332 }
307 }
333 }
308 }
334 }
@@ -769,7 +795,6 @@ Item {
769 state: getExtendedProperty(actionState, "state", "")
795 state: getExtendedProperty(actionState, "state", "")
770 enabled: menuData && menuData.sensitive || false
796 enabled: menuData && menuData.sensitive || false
771 highlightWhenPressed: false
797 highlightWhenPressed: false
772− showDivider: false
773
798
774 onTriggered: {
799 onTriggered: {
775 model.activate(modelIndex);
800 model.activate(modelIndex);
@@ -972,116 +997,43 @@ Item {
972 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-extra-label': 'string'});
997 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-extra-label': 'string'});
973 }
998 }
974
999
975− component: Component {
976− Button {
1000+ slots: Button {
977− objectName: "buttonSectionMenuControl"
1001+ objectName: "buttonSectionMenuControl"
978− text: getExtendedProperty(extendedData, "xCanonicalExtraLabel", "")
1002+ text: getExtendedProperty(extendedData, "xCanonicalExtraLabel", "")
979
1003
980− onClicked: {
1004+ onClicked: {
981− menuModel.activate(menuIndex);
1005+ menuModel.activate(menuIndex);
982− }
983 }
1006 }
984 }
1007 }
985 }
1008 }
986 }
1009 }
987
1010
988− Component {
989− id: keymapMenu;
990−
991− // FIXME this should use a "radio button" menu, once we have it in the SDK
992− ListItems.Empty {
993− id: checkItem
994− objectName: "keymapMenu"
995− property QtObject menuData: null
996− property int menuIndex: -1
997− readonly property bool serverChecked: menuData && menuData.isToggled || false
998−
999− enabled: menuData && menuData.sensitive || false
1000− highlightWhenPressed: false
1001− __acceptEvents: !serverChecked
1002−
1003− CheckBox {
1004− id: checkbox
1005− __acceptEvents: !checkItem.serverChecked
1006− anchors {
1007− left: parent.left
1008− leftMargin: checkItem.__contentsMargins
1009− verticalCenter: parent.verticalCenter
1010− }
1011− }
1012−
1013− ServerPropertySynchroniser {
1014− objectName: "sync"
1015− syncTimeout: Utils.Constants.indicatorValueTimeout
1016−
1017− serverTarget: checkItem
1018− serverProperty: "serverChecked"
1019− userTarget: checkbox
1020− userProperty: "checked"
1021−
1022− onSyncTriggered: {
1023− menuModel.activate(checkItem.menuIndex);
1024− }
1025− }
1026−
1027− Label {
1028− id: label
1029− anchors {
1030− left: checkbox.right
1031− leftMargin: checkItem.__contentsMargins
1032− right: parent.right
1033− rightMargin: checkItem.__contentsMargins
1034− verticalCenter: parent.verticalCenter
1035− }
1036− elide: Text.ElideRight
1037− text: checkItem.menuData && checkItem.menuData.label || ""
1038− }
1039−
1040− onClicked: menuModel.activate(menuIndex);
1041− }
1042− }
1043−
1044 function load(modelData, context) {
1011 function load(modelData, context) {
1045− // tweak indicator-session items
1012+ if (context && context.indexOf("fake-") == 0) {
1046− if (context === "indicator-session") {
1013+ context = context.substring("fake-".length)
1047− if ((modelData.action === "indicator.logout" || modelData.action === "indicator.suspend" || modelData.action === "indicator.hibernate" ||
1048− modelData.action === "indicator.reboot")
1049− && !Platform.isPC) {
1050− return null; // logout, suspend and hibernate hidden on devices
1051− }
1052 }
1014 }
1053
1015
1054− // specialize for indicator-keyboard
1016+ var component = getComponentForIndicatorEntryAction(context, modelData.action)
1055− if (context === "indicator-keyboard") {
1017+ if (component !== undefined) {
1056− if (modelData.isRadio) {
1018+ return component
1057− return keymapMenu;
1058− } else if (modelData.action === "indicator.map" || modelData.action === "indicator.chart") {
1059− return null; // map and chart not available
1060− }
1061 }
1019 }
1062
1020
1063− if (modelData.type !== undefined && modelData.type !== "") {
1021+ component = getComponentForIndicatorEntryType(context, modelData.type)
1064− var component = undefined;
1065−
1066− var contextComponents = _map[context];
1067− if (contextComponents !== undefined) {
1068− component = contextComponents[modelData.type];
1069− }
1070−
1071− if (component === undefined) {
1072− component = _map["default"][modelData.type];
1073− }
1074− if (component !== undefined) {
1022+ if (component !== undefined) {
1075− return component;
1023+ return component;
1076− }
1077− console.debug("Don't know how to make " + modelData.type + " for " + context);
1078 }
1024 }
1025+
1079 if (modelData.isCheck || modelData.isRadio) {
1026 if (modelData.isCheck || modelData.isRadio) {
1080 return checkableMenu;
1027 return checkableMenu;
1081 }
1028 }
1082 if (modelData.isSeparator) {
1029 if (modelData.isSeparator) {
1083 return separatorMenu;
1030 return separatorMenu;
1084 }
1031 }
1032+ if (modelData.action !== undefined && modelData.action.indexOf("settings") > -1) {
1033+ // FIXME : At the moment, the indicators aren't using
1034+ // com.canonical.indicators.link for settings menu. Need to fudge it.
1035+ return linkMenu;
1036+ }
1085 return standardMenu;
1037 return standardMenu;
1086 }
1038 }
1087}
1039}
tests/mocks/Unity/Indicators/IndicatorsModel.qml+1−1
@@ -124,7 +124,7 @@ Indicators.FakeIndicatorsModel {
124
124
125 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake0",
125 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake0",
126 getUnityMenuModelData("indicator-keyboard",
126 getUnityMenuModelData("indicator-keyboard",
127− "Czech (F)",
127+ "English (F)",
128 "",
128 "",
129 [ "image://theme/input-keyboard-symbolic" ]));
129 [ "image://theme/input-keyboard-symbolic" ]));
130 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake1",
130 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake1",
tests/mocks/Unity/Indicators/fakeindicatorsmodeldata.js+220−32
@@ -30,7 +30,7 @@ var fakeMenuData = {
30 "type": "com.canonical.indicator.messages.messageitem",
30 "type": "com.canonical.indicator.messages.messageitem",
31 "ext": {
31 "ext": {
32 "icon": "file:///usr/share/ubuntu/settings/system/icons/settings-system-update.svg",
32 "icon": "file:///usr/share/ubuntu/settings/system/icons/settings-system-update.svg",
33− "xCanonicalAppIcon": "file:///usr/share/ubuntu/settings/system/system-settings.png",
33+ "xCanonicalAppIcon": "image://theme/system-settings",
34 "xCanonicalMessageActions": null,
34 "xCanonicalMessageActions": null,
35 "xCanonicalText": "Tap to open the system updater.",
35 "xCanonicalText": "Tap to open the system updater.",
36 "xCanonicalTime": ((new Date).getTime() - 350 * 1000) * 1000,
36 "xCanonicalTime": ((new Date).getTime() - 350 * 1000) * 1000,
@@ -47,12 +47,12 @@ var fakeMenuData = {
47 "action": "indicator.telephony-service-sms.msg.MSG_ID",
47 "action": "indicator.telephony-service-sms.msg.MSG_ID",
48 "actionState": {},
48 "actionState": {},
49 "ext": {},
49 "ext": {},
50− "icon": "file:///usr/share/telephony-service/assets/avatar-default@18.png",
50+ "icon": Qt.resolvedUrl("../../../../../tests/graphics/avatars/funky@12.png"),
51 "type": "com.canonical.indicator.messages.messageitem",
51 "type": "com.canonical.indicator.messages.messageitem",
52 "ext": {
52 "ext": {
53− "icon": "file:///usr/share/telephony-service/assets/avatar-default@18.png",
53+ "icon": Qt.resolvedUrl("../../../../../tests/graphics/avatars/funky@12.png"),
54− "xCanonicalAppIcon": "image://theme/telephony-service-message",
54+ "xCanonicalAppIcon": Qt.resolvedUrl("../../../../../tests/graphics/applicationIcons/messages-app@18.png"),
55− "xCanonicalMessageActions": "",
55+ "xCanonicalMessageActions": [ { "parameter-type": "s" } ],
56 "xCanonicalText": "This is a message sent to an awesome Ubuntu phone.",
56 "xCanonicalText": "This is a message sent to an awesome Ubuntu phone.",
57 "xCanonicalTime": ((new Date).getTime() - 35 * 1000) * 1000
57 "xCanonicalTime": ((new Date).getTime() - 35 * 1000) * 1000
58 },
58 },
@@ -64,6 +64,25 @@ var fakeMenuData = {
64 "sensitive": true
64 "sensitive": true
65 }
65 }
66 },
66 },
67+ {
68+ "rowData": {
69+ "label": "+39441234567 - [SIM 2]",
70+ "sensitive": true,
71+ "isSeparator": false,
72+ "icon": "image://theme/missed-call",
73+ "type": "com.canonical.indicator.messages.messageitem",
74+ "ext": {
75+ "xCanonicalMessageActions": [ { "parameter-type": "_s" } ],
76+ "xCanonicalText": "1 Missed call.",
77+ "xCanonicalTime": ((new Date).getTime() - 350 * 1000) * 1000,
78+ },
79+ "action": "indicator.telephony-service-missed-call.call.CALL_ID",
80+ "actionState": {},
81+ "isCheck": false,
82+ "isRadio": false,
83+ "isToggled": false,
84+ }
85+ },
67 {
86 {
68 "rowData": {
87 "rowData": {
69 "action": "indicator.remove-all",
88 "action": "indicator.remove-all",
@@ -337,34 +356,72 @@ var fakeMenuData = {
337 "type": "com.canonical.indicator.root"
356 "type": "com.canonical.indicator.root"
338 },
357 },
339 "submenu": [
358 "submenu": [
340− {
359+ {
360+ "rowData": {
361+ "label": "Charge Level",
362+ "sensitive": false,
363+ "isSeparator": false,
364+ "icon": "",
365+ "type": "com.canonical.indicator.progress",
366+ "ext": {},
367+ "action": "indicator.battery-level",
368+ "actionState": "100",
369+ "isCheck": false,
370+ "isRadio": false,
371+ "isToggled": false
372+ }
373+ },
374+ {
375+
376+ "rowData": {
377+ "label": "",
378+ "sensitive": true,
379+ "isSeparator": true,
380+ "icon": "",
381+ "type": "",
382+ "ext": {},
383+ "action": "",
384+ "actionState": "",
385+ "isCheck": false,
386+ "isRadio": false,
387+ "isToggled": false
388+ }
389+ },
390+ {
391+
392+ "rowData": {
393+ "label": "",
394+ "sensitive": true,
395+ "isSeparator": false,
396+ "icon": "",
397+ "type": "com.canonical.unity.slider",
398+ "ext": {
399+ "maxIcon": "image://theme/display-brightness-max",
400+ "maxValue": "1",
401+ "minIcon": "image://theme/display-brightness-min",
402+ "minValue": "0",
403+ },
404+ "action": "indicator.brightness",
405+ "actionState": "0.212244897959184",
406+ "isCheck": false,
407+ "isRadio": false,
408+ "isToggled": false
409+ }
410+ },
411+ {
412+
341 "rowData": {
413 "rowData": {
342− "action": "indicator.activate-statistics",
414+ "label": "Auto-brightness",
343− "actionState": {},
344− "ext": {},
345− "icon": "image://theme/battery-full-charged-symbolic",
346− "isCheck": false,
347− "isRadio": false,
348− "isSeparator": false,
349− "isToggled": false,
350− "label": "Battery (full charged)",
351 "sensitive": true,
415 "sensitive": true,
416+ "isSeparator": false,
417+ "icon": "",
352− "type": "com.canonical.indicator.basic"
418+ "type": "com.canonical.indicator.switch",
353− }
354− },
355− {
356− "rowData": {
357− "action": "indicator.activate-statistics",
358− "actionState": {},
359 "ext": {},
419 "ext": {},
360− "icon": "image://theme/battery-100",
420+ "action": "indicator.auto-brightness",
421+ "actionState": false,
361− "isCheck": false,
422+ "isCheck": true,
362 "isRadio": false,
423 "isRadio": false,
363− "isSeparator": false,
364− "isToggled": false,
424+ "isToggled": false
365− "label": "Battery",
366− "sensitive": true,
367− "type": "com.canonical.indicator.basic"
368 }
425 }
369 },
426 },
370 {
427 {
@@ -555,7 +612,6 @@ var fakeMenuData = {
555 }
612 }
556 ],
613 ],
557
614
558−
559 "fake-indicator-datetime": [
615 "fake-indicator-datetime": [
560 {
616 {
561 "rowData": {
617 "rowData": {
@@ -591,6 +647,25 @@ var fakeMenuData = {
591 "type": ""
647 "type": ""
592 }
648 }
593 },
649 },
650+ {
651+ "rowData": {
652+ "action": "indicator.calendar",
653+ "actionState": {
654+ "appointment-days": "",
655+ "calendar-day": (new Date).getTime() / 1000,
656+ "show-week-numbers": false,
657+ },
658+ "ext": {},
659+ "icon": "image://theme/calendar",
660+ "isCheck": false,
661+ "isRadio": true,
662+ "isSeparator": false,
663+ "isToggled": false,
664+ "label": "[calendar]",
665+ "sensitive": true,
666+ "type": "com.canonical.indicator.calendar"
667+ }
668+ },
594 {
669 {
595 "rowData": {
670 "rowData": {
596 "action": "",
671 "action": "",
@@ -727,7 +802,6 @@ var fakeMenuData = {
727 }
802 }
728 ],
803 ],
729
804
730−
731 "fake-indicator-files": [
805 "fake-indicator-files": [
732 {
806 {
733 "rowData": {
807 "rowData": {
@@ -1102,5 +1176,119 @@ var fakeMenuData = {
1102 }
1176 }
1103 ]
1177 ]
1104 }
1178 }
1105− ]
1179+ ],
1180+
1181+ "indicator-keyboard": [
1182+ {
1183+ "rowData": {
1184+ "action": "indicator.indicator",
1185+ "actionState": {
1186+ "icons": [],
1187+ "label": "",
1188+ "title": "English (USA, QWERTY)",
1189+ "visible": true
1190+ },
1191+ "icon": "",
1192+ "isCheck": false,
1193+ "isRadio": false,
1194+ "isSeparator": false,
1195+ "isToggled": false,
1196+ "label": "",
1197+ "sensitive": true,
1198+ "type": "com.canonical.indicator.root"
1199+ },
1200+ "submenu": [
1201+ {
1202+ "rowData": {
1203+ "label": "České (QWERTY)",
1204+ "sensitive": true,
1205+ "isSeparator": false,
1206+ "icon": "image://theme/indicator-keyboard-Cs",
1207+ "type": "",
1208+ "ext": {},
1209+ "action": "indicator.current",
1210+ "actionState": 0,
1211+ "isCheck": false,
1212+ "isRadio": true,
1213+ "isToggled": false
1214+ }
1215+ },
1216+ {
1217+ "rowData": {
1218+ "label": "Italiana (QWERTY)",
1219+ "sensitive": true,
1220+ "isSeparator": false,
1221+ "icon": "image://theme/indicator-keyboard-It",
1222+ "type": "",
1223+ "ext": {},
1224+ "action": "indicator.current",
1225+ "actionState": 0,
1226+ "isCheck": false,
1227+ "isRadio": true,
1228+ "isToggled": false
1229+ }
1230+ },
1231+ {
1232+ "rowData": {
1233+ "label": "English (USA)",
1234+ "sensitive": true,
1235+ "isSeparator": false,
1236+ "icon": "image://theme/indicator-keyboard-En",
1237+ "type": "",
1238+ "ext": {},
1239+ "action": "indicator.current",
1240+ "actionState": 0,
1241+ "isCheck": false,
1242+ "isRadio": true,
1243+ "isToggled": true
1244+ }
1245+ },
1246+ {
1247+ "rowData": {
1248+ "label": "",
1249+ "sensitive": true,
1250+ "isSeparator": true,
1251+ "icon": "",
1252+ "type": "",
1253+ "ext": {},
1254+ "action": "",
1255+ "actionState": "",
1256+ "isCheck": false,
1257+ "isRadio": false,
1258+ "isToggled": false
1259+ }
1260+ },
1261+ {
1262+ "rowData": {
1263+ "label": "Character Map",
1264+ "sensitive": true,
1265+ "isSeparator": false,
1266+ "icon": "",
1267+ "type": "",
1268+ "ext": {},
1269+ "action": "indicator.map",
1270+ "actionState": "",
1271+ "isCheck": false,
1272+ "isRadio": false,
1273+ "isToggled": false
1274+ }
1275+ },
1276+ {
1277+ "rowData": {
1278+ "label": "Keyboard layout",
1279+ "sensitive": true,
1280+ "isSeparator": false,
1281+ "icon": "",
1282+ "type": "",
1283+ "ext": {},
1284+ "action": "indicator.key-map.settings",
1285+ "actionState": "",
1286+ "isCheck": false,
1287+ "isRadio": false,
1288+ "isToggled": false
1289+ }
1290+ }
1291+ ]
1292+ }
1293+ ],
1106}
1294}
tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml+1−6
@@ -396,7 +396,7 @@ Item {
396
396
397 function test_create_appointmentMenu_data() {
397 function test_create_appointmentMenu_data() {
398 return [
398 return [
399− {label: "testLabel1", enabled: true, icon: "file:///testIcon1", color: Qt.rgba(0, 0, 0, 0),
399+ {label: "testLabel1", enabled: true, icon: "file:///testIcon1", color: Qt.rgba(1, 2, 3, 0),
400 time: new Date(2014, 04, 14), timeFormat: "%a %d %b %l:%M %p"},
400 time: new Date(2014, 04, 14), timeFormat: "%a %d %b %l:%M %p"},
401 {label: "testLabel2", enabled: false, icon: "file:///testIcon2", color: Qt.rgba(1, 0, 0, 0),
401 {label: "testLabel2", enabled: false, icon: "file:///testIcon2", color: Qt.rgba(1, 0, 0, 0),
402 time: new Date(2015, 11, 31), timeFormat: "%A" },
402 time: new Date(2015, 11, 31), timeFormat: "%A" },
@@ -594,9 +594,7 @@ Item {
594 // ModemInfoItem gets all it's data through the actions.
594 // ModemInfoItem gets all it's data through the actions.
595 return [
595 return [
596 {
596 {
597− label: "",
598 enabled: true,
597 enabled: true,
599− checked: false,
600 statusLabelAction: "action::statusLabel",
598 statusLabelAction: "action::statusLabel",
601 statusIconAction: "action::statusIcon",
599 statusIconAction: "action::statusIcon",
602 connectivityIconAction: "action::connectivityIcon",
600 connectivityIconAction: "action::connectivityIcon",
@@ -609,9 +607,7 @@ Item {
609
607
610 function test_create_modemInfoItem(data) {
608 function test_create_modemInfoItem(data) {
611 menuData.type = "com.canonical.indicator.network.modeminfoitem";
609 menuData.type = "com.canonical.indicator.network.modeminfoitem";
612− menuData.label = data.label;
613 menuData.sensitive = data.enabled;
610 menuData.sensitive = data.enabled;
614− menuData.isToggled = data.checked;
615 menuData.ext = {
611 menuData.ext = {
616 'xCanonicalModemStatusLabelAction': data.statusLabelAction,
612 'xCanonicalModemStatusLabelAction': data.statusLabelAction,
617 'xCanonicalModemStatusIconAction': data.statusIconAction,
613 'xCanonicalModemStatusIconAction': data.statusIconAction,
@@ -625,7 +621,6 @@ Item {
625 loader.sourceComponent = factory.load(menuData);
621 loader.sourceComponent = factory.load(menuData);
626 tryCompareFunction(function() { return loader.item != undefined; }, true);
622 tryCompareFunction(function() { return loader.item != undefined; }, true);
627 compare(loader.item.objectName, "modemInfoItem", "Should have created a modem info item.");
623 compare(loader.item.objectName, "modemInfoItem", "Should have created a modem info item.");
628− compare(loader.item.text, data.label, "Label does not match data");
629
624
630 compare(loader.item.statusLabelAction.name, data.statusLabelAction, "StatusLabel action incorrect");
625 compare(loader.item.statusLabelAction.name, data.statusLabelAction, "StatusLabel action incorrect");
631 compare(loader.item.statusIconAction.name, data.statusIconAction, "StatusIcon action incorrect");
626 compare(loader.item.statusIconAction.name, data.statusIconAction, "StatusIcon action incorrect");
tests/qmltests/Panel/tst_IndicatorPage.qml+1−1
@@ -36,7 +36,7 @@ Item {
36 menuObjectPath: "/com/canonical/indicator/test"
36 menuObjectPath: "/com/canonical/indicator/test"
37
37
38 factory {
38 factory {
39− _map: {
39+ _userMap: {
40 "default": {
40 "default": {
41 "com.canonical.indicator.test" : testMenu
41 "com.canonical.indicator.test" : testMenu
42 }
42 }