@@ -27,7 +27,7 @@ import Ubuntu.Components 0.1
28 id: menuFactory
28 id: menuFactory
30− property var model: null
30+ property var menuModel: null
32 property var _map: {
32 property var _map: {
33 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
33 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
@@ -50,38 +50,55 @@ Item {
50 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
50 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
53+ function getExtendedProperty(object, propertyName, defaultValue) {
54+ if (object && object.hasOwnProperty(propertyName)) {
55+ return object[propertyName];
53 Component { id: divMenu; Indicators.DivMenuItem {} }
60 Component { id: divMenu; Indicators.DivMenuItem {} }
55 Component {
62 Component {
56 id: sliderMenu;
63 id: sliderMenu;
57 Indicators.SliderMenuItem {
64 Indicators.SliderMenuItem {
58− property QtObject menu: null
65+ property QtObject menuData: null
66+ property var menuModel: menuFactory.menuModel
67+ property int menuIndex: -1
68+ property var extendedData: menuData && menuData.ext || undefined
60− text: menu && menu.label ? menu.label : ""
70+ text: menuData && menuData.label || ""
61− icon: menu && menu.icon ? menu.icon : ""
71+ iconSource: menuData && menuData.icon || ""
62− minIcon: menu && menu.ext.minIcon ? menu.ext.minIcon : ""
72+ minIcon: getExtendedProperty(extendedData, "minIcon", "")
63− maxIcon: menu && menu.ext.maxIcon ? menu.ext.maxIcon : ""
73+ maxIcon: getExtendedProperty(extendedData, "maxIcon", "")
65− minimumValue: menu.ext.minValue ? menu.ext.minValue : 0.0
75+ minimumValue: getExtendedProperty(extendedData, "minValue", 0.0)
66 maximumValue: {
76 maximumValue: {
67− var maximum = menu.ext.maxValue ? menu.ext.maxValue : 1.0
77+ var maximum = getExtendedProperty(extendedData, "maxValue", 1.0);
68 if (maximum <= minimumValue) {
78 if (maximum <= minimumValue) {
69 return minimumValue + 1;
79 return minimumValue + 1;
71 return maximum;
81 return maximum;
73− value: menu ? menu.actionState : 0.0
83+ value: menuData && menuData.actionState || 0.0
74− enabled: menu ? menu.sensitive : false
84+ enabled: menuData && menuData.sensitive || false
76− Component.onCompleted: {
86+ onMenuModelChanged: {
77− model.loadExtendedAttributes(modelIndex, {'min-value': 'double',
87+ loadAttributes();
78− 'max-value': 'double',
88+ }
79− 'min-icon': 'icon',
89+ onMenuIndexChanged: {
80− 'max-icon': 'icon'});
90+ loadAttributes();
83 onChangeState: {
92 onChangeState: {
84− model.changeState(modelIndex, value);
93+ menuModel.changeState(menuIndex, value);
96+ function loadAttributes() {
97+ if (!menuModel || menuIndex == undefined) return;
98+ menuModel.loadExtendedAttributes(menuIndex, {'min-value': 'double',
99+ 'max-value': 'double',
101+ 'max-icon': 'icon'});
@@ -89,13 +106,15 @@ Item {
89 Component {
106 Component {
90 id: buttonMenu;
107 id: buttonMenu;
91 Indicators.ButtonMenuItem {
108 Indicators.ButtonMenuItem {
92− property QtObject menu: null
109+ property QtObject menuData: null
110+ property var menuModel: menuFactory.menuModel
111+ property int menuIndex: -1
94− text: menu && menu.label ? menu.label : ""
113+ text: menuData && menuData.label || ""
95− enabled: menu ? menu.sensitive : false
114+ enabled: menuData && menuData.sensitive || false
97 onActivate: {
116 onActivate: {
98− model.activate(modelIndex);
117+ menuModel.activate(menuIndex);
99 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
118 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
@@ -103,37 +122,40 @@ Item {
103 Component {
122 Component {
104 id: sectionMenu;
123 id: sectionMenu;
105 Indicators.SectionMenuItem {
124 Indicators.SectionMenuItem {
106− property QtObject menu: null
125+ property QtObject menuData: null
126+ property var menuIndex: undefined
108− text: menu && menu.label ? menu.label : ""
128+ text: menuData && menuData.label || ""
112 Component {
132 Component {
113 id: progressMenu;
133 id: progressMenu;
114 Indicators.ProgressMenuItem {
134 Indicators.ProgressMenuItem {
115− property QtObject menu: null
135+ property QtObject menuData: null
136+ property int menuIndex: -1
117− text: menu && menu.label ? menu.label : ""
138+ text: menuData && menuData.label || ""
118− icon: menu ? menu.icon : ""
139+ iconSource: menuData && menuData.icon || ""
119− value : menu ? menu.actionState : 0.0
140+ value : menuData && menuData.actionState || 0.0
120− enabled: menu ? menu.sensitive : false
141+ enabled: menuData && menuData.sensitive || false
124 Component {
145 Component {
125 id: standardMenu;
146 id: standardMenu;
126 Indicators.StandardMenuItem {
147 Indicators.StandardMenuItem {
127− property QtObject menu: null
148+ property QtObject menuData: null
149+ property int menuIndex: -1
129− text: menu && menu.label ? menu.label : ""
151+ text: menuData && menuData.label || ""
130− icon: menu && menu.icon ? menu.icon : ""
152+ iconSource: menuData && menuData.icon || ""
153+ enabled: menuData && menuData.sensitive || false
131− checkable: menu ? (menu.isCheck || menu.isRadio) : false
154+ checkable: menuData ? (menuData.isCheck || menuData.isRadio) : false
132− checked: checkable ? menu.isToggled : false
155+ checked: checkable ? menuData.isToggled : false
133− enabled: menu ? menu.sensitive : false
135 onActivate: {
157 onActivate: {
136− model.activate(modelIndex);
158+ menuModel.activate(menuIndex);
137 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
159 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
@@ -142,15 +164,16 @@ Item {
142 Component {
164 Component {
143 id: switchMenu;
165 id: switchMenu;
144 Indicators.SwitchMenuItem {
166 Indicators.SwitchMenuItem {
145− property QtObject menu: null
167+ property QtObject menuData: null
168+ property int menuIndex: -1
147− text: menu && menu.label ? menu.label : ""
170+ text: menuData && menuData.label || ""
148− icon: menu && menu.icon ? menu.icon : ""
171+ iconSource: menuData && menuData.icon || ""
172+ enabled: menuData && menuData.sensitive || false
149− checked: menu ? menu.isToggled : false
173+ checked: menuData ? menuData.isToggled : false
150− enabled: menu ? menu.sensitive : false
152 onActivate: {
175 onActivate: {
153− model.activate(modelIndex);
176+ menuModel.activate(menuIndex);
154 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
177 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
@@ -159,13 +182,24 @@ Item {
159 Component {
182 Component {
160 id: wifiSection;
183 id: wifiSection;
161 Indicators.SectionMenuItem {
184 Indicators.SectionMenuItem {
162− property QtObject menu: null
185+ property QtObject menuData: null
186+ property var menuModel: menuFactory.menuModel
187+ property int menuIndex: -1
188+ property var extendedData: menuData && menuData.ext || undefined
190+ text: menuData && menuData.label || ""
191+ busy: getExtendedProperty(extendedData, "xCanonicalBusyAction", false)
164− text: menu && menu.label ? menu.label : ""
193+ onMenuModelChanged: {
165− busy: menu ? menu.ext.xCanonicalBusyAction : false
194+ loadAttributes();
196+ onMenuIndexChanged: {
167− Component.onCompleted: {
200+ function loadAttributes() {
201+ if (!menuModel || menuIndex == undefined) return;
168− model.loadExtendedAttributes(modelIndex, {'x-canonical-busy-action': 'bool'});
202+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'})
@@ -173,67 +207,81 @@ Item {
173 Component {
207 Component {
174 id: accessPoint;
208 id: accessPoint;
175 ICNetwork.AccessPoint {
209 ICNetwork.AccessPoint {
176− property QtObject menu: null
210+ property QtObject menuData: null
211+ property var menuModel: menuFactory.menuModel
212+ property int menuIndex: -1
213+ property var extendedData: menuData && menuData.ext || undefined
177 property var strengthAction: QMenuModel.UnityMenuAction {
215 property var strengthAction: QMenuModel.UnityMenuAction {
178− model: menuFactory.model ? menuFactory.model : null
216+ model: menuModel
179− index: modelIndex
217+ index: menuIndex
180− name: menu ? menu.ext.xCanonicalWifiApStrengthAction : ""
218+ name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
183− text: menu && menu.label ? menu.label : ""
221+ text: menuData && menuData.label || ""
222+ enabled: menuData && menuData.sensitive || false
184− secure: menu ? menu.ext.xCanonicalWifiApIsSecure : false
223+ secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
185− adHoc: menu ? menu.ext.xCanonicalWifiApIsAdhoc : false
224+ adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
186− checked: menu ? menu.isToggled : false
225+ checked: menuData ? menuData.isToggled : false
187 signalStrength: strengthAction.valid ? strengthAction.state : 0
226 signalStrength: strengthAction.valid ? strengthAction.state : 0
188− enabled: menu ? menu.sensitive : false
190− Component.onCompleted: {
228+ onMenuModelChanged: {
191− model.loadExtendedAttributes(modelIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
229+ loadAttributes();
192− 'x-canonical-wifi-ap-is-secure': 'bool',
230+ }
193− 'x-canonical-wifi-ap-strength-action': 'string'});
231+ onMenuIndexChanged: {
195 onActivate: {
234 onActivate: {
196− model.activate(modelIndex);
235+ menuModel.activate(menuIndex);
197 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
236 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
239+ function loadAttributes() {
240+ if (!menuModel || menuIndex == undefined) return;
241+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
242+ 'x-canonical-wifi-ap-is-secure': 'bool',
243+ 'x-canonical-wifi-ap-strength-action': 'string'});
202 Component {
248 Component {
203 id: messageItem
249 id: messageItem
204 ICMessaging.MessageMenuItemFactory {
250 ICMessaging.MessageMenuItemFactory {
205−
251+ menuModel: menuFactory.menuModel
206− property QtObject menu: null
207− model: menuFactory.model ? menuFactory.model : null
209− Component.onCompleted: {
210− model.loadExtendedAttributes(modelIndex, {'x-canonical-time': 'int64',
211− 'x-canonical-text': 'string',
212− 'x-canonical-message-actions': 'variant',
214− 'x-canonical-app-icon': 'icon'});
219 Component {
255 Component {
220 id: groupedMessage
256 id: groupedMessage
221 ICMessaging.GroupedMessage {
257 ICMessaging.GroupedMessage {
222− property QtObject menu: null
258+ property QtObject menuData: null
223−
259+ property var menuModel: menuFactory.menuModel
224− title: menu && menu.label ? menu.label : ""
260+ property int menuIndex: -1
225− count: menu && menu.actionState[0] ? menu.actionState[0] : "0"
261+ property var extendedData: menuData && menuData.ext || undefined
263+ title: menuData && menuData.label || ""
226− appIcon: menu && menu.ext.icon !== undefined ? menu.ext.icon : "qrc:/indicators/artwork/messaging/default_app.svg"
264+ appIcon: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_app.svg")
227−
265+ count: menuData && menuData.actionState.length > 0 ? menuData.actionState[0] : "0"
228− Component.onCompleted: {
266+ enabled: menuData && menuData.sensitive || false
229− model.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
267+
268+ onMenuModelChanged: {
271+ onMenuIndexChanged: {
231 onActivateApp: {
274 onActivateApp: {
232− model.activate(modelIndex, true);
275+ menuModel.activate(menuIndex, true);
233 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
276 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
235 onDismiss: {
278 onDismiss: {
236− model.activate(modelIndex, false);
279+ menuModel.activate(menuIndex, false);
282+ function loadAttributes() {
283+ if (!menuModel || menuIndex == undefined) return;
284+ menuModel.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
@@ -244,10 +292,9 @@ Item {
244 if (component !== undefined) {
292 if (component !== undefined) {
245 return component;
293 return component;
248− if (modelData.isSeparator) {
296+ if (modelData.isSeparator) {
249− return divMenu;
297+ return divMenu;
252 return standardMenu;
299 return standardMenu;