@@ -26,7 +26,7 @@ import QMenuModel 0.1 as QMenuModel
2626Item {
2727 id: menuFactory
2828
29− property var model: null
29+ property var menuModel: null
3030
3131 property var _map: {
3232 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
@@ -54,84 +54,99 @@ Item {
5454 Component {
5555 id: sliderMenu;
5656 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
5861
59− text: menu && menu.label ? menu.label : ""
60− icon: menu && menu.icon ? menu.icon : ""
61− minIcon: menu && menu.ext.minIcon ? menu.ext.minIcon : ""
62− maxIcon: menu && menu.ext.maxIcon ? menu.ext.maxIcon : ""
62+ text: menuItem && menuItem.label ? menuItem.label : ""
63+ icon: menuItem && menuItem.icon ? menuItem.icon : ""
64+ minIcon: extAttrib && extAttrib.hasOwnProperty("minIcon") ? extAttrib.minIcon : ""
65+ maxIcon: extAttrib && extAttrib.hasOwnProperty("maxIcon") ? extAttrib.maxIcon : ""
6366
64− minimumValue: menu.ext.minValue ? menu.ext.minValue : 0.0
67+ minimumValue: extAttrib && extAttrib.hasOwnProperty("minValue") ? extAttrib.minValue : 0.0
6568 maximumValue: {
66− var maximum = menu.ext.maxValue ? menu.ext.maxValue : 1.0
69+ var maximum = extAttrib && extAttrib.hasOwnProperty("maxValue") ? extAttrib.maxValue : 1.0
6770 if (maximum <= minimumValue) {
6871 return minimumValue + 1;
6972 }
7073 return maximum;
7174 }
72− value: menu ? menu.actionState : 0.0
73− enabled: menu ? menu.sensitive : false
75+ value: menuItem ? menuItem.actionState : 0.0
76+ enabled: menuItem ? menuItem.sensitive : false
7477
75− Component.onCompleted: {
76− model.loadExtendedAttributes(modelIndex, {'min-value': 'double',
78+ onMenuModelChanged: {
79+ loadAttributes();
80+ }
81+ onMenuIndexChanged: {
82+ loadAttributes();
83+ }
84+ onChangeState: {
85+ menuModel.changeState(menuIndex, value);
86+ }
87+
88+ function loadAttributes() {
89+ if (!menuModel || menuIndex == undefined) return;
90+ menuModel.loadExtendedAttributes(menuIndex, {'min-value': 'double',
7791 'max-value': 'double',
7892 'min-icon': 'icon',
7993 'max-icon': 'icon'});
8094 }
81−
82− onChangeState: {
83− model.changeState(modelIndex, value);
84− }
8595 }
8696 }
8797
8898 Component {
8999 id: buttonMenu;
90100 Indicators.ButtonMenuItem {
91− property QtObject menu: null
101+ property QtObject menuItem: null
102+ property var menuModel: menuFactory.menuModel
103+ property var menuIndex: undefined
92104
93− text: menu && menu.label ? menu.label : ""
94− enabled: menu ? menu.sensitive : false
105+ text: menuItem && menuItem.label ? menuItem.label : ""
106+ enabled: menuItem ? menuItem.sensitive : false
95107
96108 onActivate: {
97− model.activate(modelIndex);
109+ menuModel.activate(menuIndex);
98110 }
99111 }
100112 }
101113 Component {
102114 id: sectionMenu;
103115 Indicators.SectionMenuItem {
104− property QtObject menu: null
116+ property QtObject menuItem: null
117+ property var menuIndex: undefined
105118
106− text: menu && menu.label ? menu.label : ""
119+ text: menuItem && menuItem.label ? menuItem.label : ""
107120 }
108121 }
109122
110123 Component {
111124 id: progressMenu;
112125 Indicators.ProgressMenuItem {
113− property QtObject menu: null
126+ property QtObject menuItem: null
127+ property var menuIndex: undefined
114128
115− text: menu && menu.label ? menu.label : ""
116− icon: menu ? menu.icon : ""
117− value : menu ? menu.actionState : 0.0
118− enabled: menu ? menu.sensitive : false
129+ text: menuItem && menuItem.label ? menuItem.label : ""
130+ icon: menuItem ? menuItem.icon : ""
131+ value : menuItem ? menuItem.actionState : 0.0
132+ enabled: menuItem ? menuItem.sensitive : false
119133 }
120134 }
121135
122136 Component {
123137 id: standardMenu;
124138 Indicators.StandardMenuItem {
125− property QtObject menu: null
139+ property QtObject menuItem: null
140+ property var menuIndex: undefined
126141
127− text: menu && menu.label ? menu.label : ""
128− icon: menu && menu.icon ? menu.icon : ""
129− checkable: menu ? (menu.isCheck || menu.isRadio) : false
130− checked: checkable ? menu.isToggled : false
131− enabled: menu ? menu.sensitive : false
142+ text: menuItem && menuItem.label ? menuItem.label : ""
143+ icon: menuItem && menuItem.icon ? menuItem.icon : ""
144+ checkable: menuItem ? (menuItem.isCheck || menuItem.isRadio) : false
145+ checked: checkable ? menuItem.isToggled : false
146+ enabled: menuItem ? menuItem.sensitive : false
132147
133148 onActivate: {
134− model.activate(modelIndex);
149+ menuModel.activate(menuIndex);
135150 }
136151 }
137152 }
@@ -139,15 +154,16 @@ Item {
139154 Component {
140155 id: switchMenu;
141156 Indicators.SwitchMenuItem {
142− property QtObject menu: null
157+ property QtObject menuItem: null
158+ property var menuIndex: undefined
143159
144− text: menu && menu.label ? menu.label : ""
145− icon: menu && menu.icon ? menu.icon : ""
146− checked: menu ? menu.isToggled : false
147− enabled: menu ? menu.sensitive : false
160+ text: menuItem && menuItem.label ? menuItem.label : ""
161+ icon: menuItem && menuItem.icon ? menuItem.icon : ""
162+ checked: menuItem ? menuItem.isToggled : false
163+ enabled: menuItem ? menuItem.sensitive : false
148164
149165 onActivate: {
150− model.activate(modelIndex);
166+ menuModel.activate(menuIndex);
151167 }
152168 }
153169 }
@@ -155,13 +171,24 @@ Item {
155171 Component {
156172 id: wifiSection;
157173 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
178+
179+ text: menuItem && menuItem.label ? menuItem.label : ""
180+ busy: extAttrib && extAttrib.hasOwnProperty("xCanonicalBusyAction") ? extAttrib.xCanonicalBusyAction : false
159181
160− text: menu && menu.label ? menu.label : ""
161− busy: menu ? menu.ext.xCanonicalBusyAction : false
182+ onMenuModelChanged: {
183+ loadAttributes();
184+ }
185+ onMenuIndexChanged: {
186+ loadAttributes();
187+ }
162188
163− Component.onCompleted: {
164− model.loadExtendedAttributes(modelIndex, {'x-canonical-busy-action': 'bool'});
189+ function loadAttributes() {
190+ if (!menuModel || menuIndex == undefined) return;
191+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'})
165192 }
166193 }
167194 }
@@ -169,27 +196,39 @@ Item {
169196 Component {
170197 id: accessPoint;
171198 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
203+
173204 property var strengthAction: QMenuModel.UnityMenuAction {
174− model: menuFactory.model ? menuFactory.model : null
175− index: modelIndex
176− name: menu ? menu.ext.xCanonicalWifiApStrengthAction : ""
205+ model: menuModel
206+ index: menuIndex
207+ name: extAttrib && extAttrib.hasOwnProperty("xCanonicalWifiApStrengthAction") ? extAttrib.xCanonicalWifiApStrengthAction : ""
177208 }
178209
179− text: menu && menu.label ? menu.label : ""
180− secure: menu ? menu.ext.xCanonicalWifiApIsSecure : false
181− adHoc: menu ? menu.ext.xCanonicalWifiApIsAdhoc : false
182− checked: menu ? menu.isToggled : false
210+ text: menuItem && menuItem.label ? menuItem.label : ""
211+ secure: extAttrib && extAttrib.hasOwnProperty("xCanonicalWifiApIsSecure") ? extAttrib.xCanonicalWifiApIsSecure : false
212+ adHoc: extAttrib && extAttrib.hasOwnProperty("xCanonicalWifiApIsAdhoc") ? extAttrib.xCanonicalWifiApIsAdhoc : false
213+ checked: menuItem ? menuItem.isToggled : false
183214 signalStrength: strengthAction.valid ? strengthAction.state : 0
184− enabled: menu ? menu.sensitive : false
215+ enabled: menuItem ? menuItem.sensitive : false
185216
186− Component.onCompleted: {
187− model.loadExtendedAttributes(modelIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
188− 'x-canonical-wifi-ap-is-secure': 'bool',
189− 'x-canonical-wifi-ap-strength-action': 'string'});
217+ onMenuModelChanged: {
218+ loadAttributes();
219+ }
220+ onMenuIndexChanged: {
221+ loadAttributes();
190222 }
191223 onActivate: {
192− model.activate(modelIndex);
224+ menuModel.activate(menuIndex);
225+ }
226+
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'});
193232 }
194233 }
195234 }
@@ -197,37 +236,38 @@ Item {
197236 Component {
198237 id: messageItem
199238 ICMessaging.MessageMenuItemFactory {
200−
201− property QtObject menu: null
202− model: menuFactory.model ? menuFactory.model : null
203−
204− Component.onCompleted: {
205− model.loadExtendedAttributes(modelIndex, {'x-canonical-time': 'int64',
206− 'x-canonical-text': 'string',
207− 'x-canonical-message-actions': 'variant',
208− 'icon': 'icon',
209− 'x-canonical-app-icon': 'icon'});
210− }
239+ menuModel: menuFactory.menuModel
211240 }
212241 }
213242
214243 Component {
215244 id: groupedMessage
216245 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
218250
219− title: menu && menu.label ? menu.label : ""
220− count: menu && menu.actionState[0] ? menu.actionState[0] : "0"
221− appIcon: menu && menu.ext.icon !== undefined ? menu.ext.icon : "qrc:/indicators/artwork/messaging/default_app.svg"
251+ title: menuItem && menuItem.label ? menuItem.label : ""
252+ count: menuItem && menuItem.actionState.length > 0 ? menuItem.actionState[0] : "0"
253+ appIcon: extAttrib && extAttrib.hasOwnProperty("icon") ? extAttrib.icon : "qrc:/indicators/artwork/messaging/default_app.svg"
222254
223− Component.onCompleted: {
224− model.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
255+ onMenuModelChanged: {
256+ loadAttributes();
257+ }
258+ onMenuIndexChanged: {
259+ loadAttributes();
225260 }
226261 onActivateApp: {
227− model.activate(modelIndex, true);
262+ menuModel.activate(menuIndex, true);
228263 }
229264 onDismiss: {
230− model.activate(modelIndex, false);
265+ menuModel.activate(menuIndex, false);
266+ }
267+
268+ function loadAttributes() {
269+ if (!menuModel || menuIndex == undefined) return;
270+ menuModel.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
231271 }
232272 }
233273 }