@@ -26,7 +26,7 @@ import QMenuModel 0.1 as QMenuModel
27 id: menuFactory
27 id: menuFactory
29− property var model: null
29+ property var menuModel: null
31 property var _map: {
31 property var _map: {
32 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
32 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
@@ -54,84 +54,99 @@ Item {
54 Component {
54 Component {
55 id: sliderMenu;
55 id: sliderMenu;
56 Indicators.SliderMenuItem {
56 Indicators.SliderMenuItem {
57− property QtObject menu: null
57+ property QtObject menuItem: null
58+ property var menuModel: menuFactory.menuModel
59+ property var menuIndex: undefined
60+ property var extAttrib: menuItem && menuItem.ext ? menuItem.ext : undefined
59− text: menu && menu.label ? menu.label : ""
62+ text: menuItem && menuItem.label ? menuItem.label : ""
60− icon: menu && menu.icon ? menu.icon : ""
63+ icon: menuItem && menuItem.icon ? menuItem.icon : ""
61− minIcon: menu && menu.ext.minIcon ? menu.ext.minIcon : ""
64+ minIcon: extAttrib && extAttrib.hasOwnProperty("minIcon") ? extAttrib.minIcon : ""
62− maxIcon: menu && menu.ext.maxIcon ? menu.ext.maxIcon : ""
65+ maxIcon: extAttrib && extAttrib.hasOwnProperty("maxIcon") ? extAttrib.maxIcon : ""
64− minimumValue: menu.ext.minValue ? menu.ext.minValue : 0.0
67+ minimumValue: extAttrib && extAttrib.hasOwnProperty("minValue") ? extAttrib.minValue : 0.0
65 maximumValue: {
68 maximumValue: {
66− var maximum = menu.ext.maxValue ? menu.ext.maxValue : 1.0
69+ var maximum = extAttrib && extAttrib.hasOwnProperty("maxValue") ? extAttrib.maxValue : 1.0
67 if (maximum <= minimumValue) {
70 if (maximum <= minimumValue) {
68 return minimumValue + 1;
71 return minimumValue + 1;
70 return maximum;
73 return maximum;
72− value: menu ? menu.actionState : 0.0
75+ value: menuItem ? menuItem.actionState : 0.0
73− enabled: menu ? menu.sensitive : false
76+ enabled: menuItem ? menuItem.sensitive : false
75− Component.onCompleted: {
78+ onMenuModelChanged: {
81+ onMenuIndexChanged: {
85+ menuModel.changeState(menuIndex, value);
88+ function loadAttributes() {
89+ if (!menuModel || menuIndex == undefined) return;
76− model.loadExtendedAttributes(modelIndex, {'min-value': 'double',
90+ menuModel.loadExtendedAttributes(menuIndex, {'min-value': 'double',
77 'max-value': 'double',
91 'max-value': 'double',
78 'min-icon': 'icon',
92 'min-icon': 'icon',
79 'max-icon': 'icon'});
93 'max-icon': 'icon'});
83− model.changeState(modelIndex, value);
88 Component {
98 Component {
89 id: buttonMenu;
99 id: buttonMenu;
90 Indicators.ButtonMenuItem {
100 Indicators.ButtonMenuItem {
91− property QtObject menu: null
101+ property QtObject menuItem: null
102+ property var menuModel: menuFactory.menuModel
103+ property var menuIndex: undefined
93− text: menu && menu.label ? menu.label : ""
105+ text: menuItem && menuItem.label ? menuItem.label : ""
94− enabled: menu ? menu.sensitive : false
106+ enabled: menuItem ? menuItem.sensitive : false
96 onActivate: {
108 onActivate: {
97− model.activate(modelIndex);
109+ menuModel.activate(menuIndex);
101 Component {
113 Component {
102 id: sectionMenu;
114 id: sectionMenu;
103 Indicators.SectionMenuItem {
115 Indicators.SectionMenuItem {
104− property QtObject menu: null
116+ property QtObject menuItem: null
117+ property var menuIndex: undefined
106− text: menu && menu.label ? menu.label : ""
119+ text: menuItem && menuItem.label ? menuItem.label : ""
110 Component {
123 Component {
111 id: progressMenu;
124 id: progressMenu;
112 Indicators.ProgressMenuItem {
125 Indicators.ProgressMenuItem {
113− property QtObject menu: null
126+ property QtObject menuItem: null
127+ property var menuIndex: undefined
115− text: menu && menu.label ? menu.label : ""
129+ text: menuItem && menuItem.label ? menuItem.label : ""
116− icon: menu ? menu.icon : ""
130+ icon: menuItem ? menuItem.icon : ""
117− value : menu ? menu.actionState : 0.0
131+ value : menuItem ? menuItem.actionState : 0.0
118− enabled: menu ? menu.sensitive : false
132+ enabled: menuItem ? menuItem.sensitive : false
122 Component {
136 Component {
123 id: standardMenu;
137 id: standardMenu;
124 Indicators.StandardMenuItem {
138 Indicators.StandardMenuItem {
125− property QtObject menu: null
139+ property QtObject menuItem: null
140+ property var menuIndex: undefined
127− text: menu && menu.label ? menu.label : ""
142+ text: menuItem && menuItem.label ? menuItem.label : ""
128− icon: menu && menu.icon ? menu.icon : ""
143+ icon: menuItem && menuItem.icon ? menuItem.icon : ""
129− checkable: menu ? (menu.isCheck || menu.isRadio) : false
144+ checkable: menuItem ? (menuItem.isCheck || menuItem.isRadio) : false
130− checked: checkable ? menu.isToggled : false
145+ checked: checkable ? menuItem.isToggled : false
131− enabled: menu ? menu.sensitive : false
146+ enabled: menuItem ? menuItem.sensitive : false
133 onActivate: {
148 onActivate: {
134− model.activate(modelIndex);
149+ menuModel.activate(menuIndex);
@@ -139,15 +154,16 @@ Item {
139 Component {
154 Component {
140 id: switchMenu;
155 id: switchMenu;
141 Indicators.SwitchMenuItem {
156 Indicators.SwitchMenuItem {
142− property QtObject menu: null
157+ property QtObject menuItem: null
158+ property var menuIndex: undefined
144− text: menu && menu.label ? menu.label : ""
160+ text: menuItem && menuItem.label ? menuItem.label : ""
145− icon: menu && menu.icon ? menu.icon : ""
161+ icon: menuItem && menuItem.icon ? menuItem.icon : ""
146− checked: menu ? menu.isToggled : false
162+ checked: menuItem ? menuItem.isToggled : false
147− enabled: menu ? menu.sensitive : false
163+ enabled: menuItem ? menuItem.sensitive : false
149 onActivate: {
165 onActivate: {
150− model.activate(modelIndex);
166+ menuModel.activate(menuIndex);
@@ -155,13 +171,24 @@ Item {
155 Component {
171 Component {
156 id: wifiSection;
172 id: wifiSection;
157 Indicators.SectionMenuItem {
173 Indicators.SectionMenuItem {
158− property QtObject menu: null
174+ property QtObject menuItem: null
175+ property var menuModel: menuFactory.menuModel
176+ property var menuIndex: undefined
177+ property var extAttrib: menuItem && menuItem.ext ? menuItem.ext : undefined
179+ text: menuItem && menuItem.label ? menuItem.label : ""
180+ busy: extAttrib && extAttrib.hasOwnProperty("xCanonicalBusyAction") ? extAttrib.xCanonicalBusyAction : false
160− text: menu && menu.label ? menu.label : ""
182+ onMenuModelChanged: {
161− busy: menu ? menu.ext.xCanonicalBusyAction : false
183+ loadAttributes();
185+ onMenuIndexChanged: {
163− Component.onCompleted: {
189+ function loadAttributes() {
190+ if (!menuModel || menuIndex == undefined) return;
164− model.loadExtendedAttributes(modelIndex, {'x-canonical-busy-action': 'bool'});
191+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'})
@@ -169,27 +196,39 @@ Item {
169 Component {
196 Component {
170 id: accessPoint;
197 id: accessPoint;
171 ICNetwork.AccessPoint {
198 ICNetwork.AccessPoint {
172− property QtObject menu: null
199+ property QtObject menuItem: null
200+ property var menuModel: menuFactory.menuModel
201+ property var menuIndex: undefined
202+ property var extAttrib: menuItem && menuItem.ext ? menuItem.ext : undefined
173 property var strengthAction: QMenuModel.UnityMenuAction {
204 property var strengthAction: QMenuModel.UnityMenuAction {
174− model: menuFactory.model ? menuFactory.model : null
205+ model: menuModel
175− index: modelIndex
206+ index: menuIndex
176− name: menu ? menu.ext.xCanonicalWifiApStrengthAction : ""
207+ name: extAttrib && extAttrib.hasOwnProperty("xCanonicalWifiApStrengthAction") ? extAttrib.xCanonicalWifiApStrengthAction : ""
179− text: menu && menu.label ? menu.label : ""
210+ text: menuItem && menuItem.label ? menuItem.label : ""
180− secure: menu ? menu.ext.xCanonicalWifiApIsSecure : false
211+ secure: extAttrib && extAttrib.hasOwnProperty("xCanonicalWifiApIsSecure") ? extAttrib.xCanonicalWifiApIsSecure : false
181− adHoc: menu ? menu.ext.xCanonicalWifiApIsAdhoc : false
212+ adHoc: extAttrib && extAttrib.hasOwnProperty("xCanonicalWifiApIsAdhoc") ? extAttrib.xCanonicalWifiApIsAdhoc : false
182− checked: menu ? menu.isToggled : false
213+ checked: menuItem ? menuItem.isToggled : false
183 signalStrength: strengthAction.valid ? strengthAction.state : 0
214 signalStrength: strengthAction.valid ? strengthAction.state : 0
184− enabled: menu ? menu.sensitive : false
215+ enabled: menuItem ? menuItem.sensitive : false
186− Component.onCompleted: {
217+ onMenuModelChanged: {
187− model.loadExtendedAttributes(modelIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
218+ loadAttributes();
188− 'x-canonical-wifi-ap-is-secure': 'bool',
219+ }
189− 'x-canonical-wifi-ap-strength-action': 'string'});
220+ onMenuIndexChanged: {
191 onActivate: {
223 onActivate: {
192− model.activate(modelIndex);
224+ menuModel.activate(menuIndex);
227+ function loadAttributes() {
228+ if (!menuModel || menuIndex == undefined) return;
229+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
230+ 'x-canonical-wifi-ap-is-secure': 'bool',
231+ 'x-canonical-wifi-ap-strength-action': 'string'});
@@ -197,37 +236,38 @@ Item {
197 Component {
236 Component {
198 id: messageItem
237 id: messageItem
199 ICMessaging.MessageMenuItemFactory {
238 ICMessaging.MessageMenuItemFactory {
200−
239+ menuModel: menuFactory.menuModel
201− property QtObject menu: null
202− model: menuFactory.model ? menuFactory.model : null
204− Component.onCompleted: {
205− model.loadExtendedAttributes(modelIndex, {'x-canonical-time': 'int64',
206− 'x-canonical-text': 'string',
207− 'x-canonical-message-actions': 'variant',
209− 'x-canonical-app-icon': 'icon'});
214 Component {
243 Component {
215 id: groupedMessage
244 id: groupedMessage
216 ICMessaging.GroupedMessage {
245 ICMessaging.GroupedMessage {
217− property QtObject menu: null
246+ property QtObject menuItem: null
247+ property var menuModel: menuFactory.menuModel
248+ property var menuIndex: undefined
249+ property var extAttrib: menuItem && menuItem.ext ? menuItem.ext : undefined
219− title: menu && menu.label ? menu.label : ""
251+ title: menuItem && menuItem.label ? menuItem.label : ""
220− count: menu && menu.actionState[0] ? menu.actionState[0] : "0"
252+ count: menuItem && menuItem.actionState.length > 0 ? menuItem.actionState[0] : "0"
221− appIcon: menu && menu.ext.icon !== undefined ? menu.ext.icon : "qrc:/indicators/artwork/messaging/default_app.svg"
253+ appIcon: extAttrib && extAttrib.hasOwnProperty("icon") ? extAttrib.icon : "qrc:/indicators/artwork/messaging/default_app.svg"
223− Component.onCompleted: {
255+ onMenuModelChanged: {
224− model.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
256+ loadAttributes();
258+ onMenuIndexChanged: {
226 onActivateApp: {
261 onActivateApp: {
227− model.activate(modelIndex, true);
262+ menuModel.activate(menuIndex, true);
229 onDismiss: {
264 onDismiss: {
230− model.activate(modelIndex, false);
265+ menuModel.activate(menuIndex, false);
268+ function loadAttributes() {
269+ if (!menuModel || menuIndex == undefined) return;
270+ menuModel.loadExtendedAttributes(modelIndex, {'icon': 'icon'});