@@ -18,11 +18,10 @@
1818 */
1919
2020import QtQuick 2.0
21−import Unity.Indicators 0.1 as Indicators
22−import Unity.Indicators.Network 0.1 as ICNetwork
23−import Unity.Indicators.Messaging 0.1 as ICMessaging
21+import Ubuntu.Settings.Menus 0.1 as Menus
2422import QMenuModel 0.1 as QMenuModel
25−import Ubuntu.Components 0.1
23+import Unity.Indicators 0.1 as Indicators
24+import Ubuntu.Components.ListItems 0.1 as ListItems
2625
2726Item {
2827 id: menuFactory
@@ -33,12 +32,14 @@ Item {
3332 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
3433 "unity.widgets.systemsettings.tablet.switch" : switchMenu,
3534
36− "com.canonical.indicator.button" : buttonMenu,
37− "com.canonical.indicator.div" : divMenu,
38− "com.canonical.indicator.section" : sectionMenu,
39− "com.canonical.indicator.progress" : progressMenu,
40− "com.canonical.indicator.slider" : sliderMenu,
41− "com.canonical.indicator.switch" : switchMenu,
35+ "com.canonical.indicator.button" : buttonMenu,
36+ "com.canonical.indicator.div" : separatorMenu,
37+ "com.canonical.indicator.section" : sectionMenu,
38+ "com.canonical.indicator.progress" : progressMenu,
39+ "com.canonical.indicator.slider" : sliderMenu,
40+ "com.canonical.indicator.switch" : switchMenu,
41+ "com.canonical.indicator.alarm" : alarmMenu,
42+ "com.canonical.indicator.appointment" : appointmentMenu,
4243
4344 "com.canonical.indicator.messages.messageitem" : messageItem,
4445 "com.canonical.indicator.messages.sourceitem" : groupedMessage,
@@ -46,6 +47,9 @@ Item {
4647 "com.canonical.unity.slider" : sliderMenu,
4748 "com.canonical.unity.switch" : switchMenu,
4849
50+ "com.canonical.unity.media-player" : mediaPayerMenu,
51+ "com.canonical.unity.playback-item" : playbackItemMenu,
52+
4953 "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
5054 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
5155 }
@@ -58,15 +62,15 @@ Item {
5862 }
5963
6064 Component {
61− id: divMenu;
62− Indicators.DivMenuItem {
63− objectName: "divMenu"
65+ id: separatorMenu;
66+ Menus.SeparatorMenu {
67+ objectName: "separatorMenu"
6468 }
6569 }
6670
6771 Component {
6872 id: sliderMenu;
69− Indicators.SliderMenuItem {
73+ Menus.SliderMenu {
7074 objectName: "sliderMenu"
7175 property QtObject menuData: null
7276 property var menuModel: menuFactory.menuModel
@@ -95,12 +99,12 @@ Item {
9599 onMenuIndexChanged: {
96100 loadAttributes();
97101 }
98− onChangeState: {
102+ onUpdated: {
99103 menuModel.changeState(menuIndex, value);
100104 }
101105
102106 function loadAttributes() {
103− if (!menuModel || menuIndex == undefined) return;
107+ if (!menuModel || menuIndex == -1) return;
104108 menuModel.loadExtendedAttributes(menuIndex, {'min-value': 'double',
105109 'max-value': 'double',
106110 'min-icon': 'icon',
@@ -111,7 +115,7 @@ Item {
111115
112116 Component {
113117 id: buttonMenu;
114− Indicators.ButtonMenuItem {
118+ Menus.ButtonMenu {
115119 objectName: "buttonMenu"
116120 property QtObject menuData: null
117121 property var menuModel: menuFactory.menuModel
@@ -120,7 +124,7 @@ Item {
120124 buttonText: menuData && menuData.label || ""
121125 enabled: menuData && menuData.sensitive || false
122126
123− onActivate: {
127+ onTriggered: {
124128 menuModel.activate(menuIndex);
125129 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
126130 }
@@ -128,18 +132,19 @@ Item {
128132 }
129133 Component {
130134 id: sectionMenu;
131− Indicators.SectionMenuItem {
135+ Menus.SectionMenu {
132136 objectName: "sectionMenu"
133137 property QtObject menuData: null
134138 property var menuIndex: undefined
135139
136140 text: menuData && menuData.label || ""
141+ busy: false
137142 }
138143 }
139144
140145 Component {
141146 id: progressMenu;
142− Indicators.ProgressMenuItem {
147+ Menus.ProgressValueMenu {
143148 objectName: "progressMenu"
144149 property QtObject menuData: null
145150 property int menuIndex: -1
@@ -153,7 +158,7 @@ Item {
153158
154159 Component {
155160 id: standardMenu;
156− Indicators.StandardMenuItem {
161+ ListItems.Standard {
157162 objectName: "standardMenu"
158163 property QtObject menuData: null
159164 property int menuIndex: -1
@@ -161,10 +166,8 @@ Item {
161166 text: menuData && menuData.label || ""
162167 iconSource: menuData && menuData.icon || ""
163168 enabled: menuData && menuData.sensitive || false
164− checkable: menuData ? (menuData.isCheck || menuData.isRadio) : false
165− checked: checkable ? menuData.isToggled : false
166169
167− onActivate: {
170+ onTriggered: {
168171 menuModel.activate(menuIndex);
169172 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
170173 }
@@ -173,7 +176,7 @@ Item {
173176
174177 Component {
175178 id: switchMenu;
176− Indicators.SwitchMenuItem {
179+ Menus.SwitchMenu {
177180 objectName: "switchMenu"
178181 property QtObject menuData: null
179182 property int menuIndex: -1
@@ -181,18 +184,96 @@ Item {
181184 text: menuData && menuData.label || ""
182185 iconSource: menuData && menuData.icon || ""
183186 enabled: menuData && menuData.sensitive || false
184− checked: menuData ? menuData.isToggled : false
187+ checked: menuData && menuData.isToggled || false
185188
186− onActivate: {
189+ onTriggered: {
187190 menuModel.activate(menuIndex);
188191 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
189192 }
190193 }
191194 }
192195
196+ Component {
197+ id: alarmMenu;
198+ Menus.EventMenu {
199+ objectName: "alarmMenu"
200+ property QtObject menuData: null
201+ property var menuModel: menuFactory.menuModel
202+ property int menuIndex: -1
203+ property var extendedData: menuData && menuData.ext || undefined
204+ // TODO - bug #1260728
205+ property var timeFormatter: Indicators.TimeFormatter {
206+ time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
207+// format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
208+ format: "hh:mm - MMM dd"
209+ }
210+
211+ text: menuData && menuData.label || ""
212+ iconSource: menuData && menuData.icon || "image://theme/alarm-clock"
213+ time: timeFormatter.timeString
214+ enabled: menuData && menuData.sensitive || false
215+
216+ onMenuModelChanged: {
217+ loadAttributes();
218+ }
219+ onMenuIndexChanged: {
220+ loadAttributes();
221+ }
222+ onTriggered: {
223+ menuModel.activate(menuIndex);
224+ }
225+
226+ function loadAttributes() {
227+ if (!menuModel || menuIndex == -1) return;
228+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-time': 'int64',
229+ 'x-canonical-time-format': 'string'});
230+ }
231+ }
232+ }
233+
234+ Component {
235+ id: appointmentMenu;
236+ Menus.EventMenu {
237+ objectName: "appointmentMenu"
238+ property QtObject menuData: null
239+ property var menuModel: menuFactory.menuModel
240+ property int menuIndex: -1
241+ property var extendedData: menuData && menuData.ext || undefined
242+ // TODO - bug #1260728
243+ property var timeFormatter: Indicators.TimeFormatter {
244+ time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
245+// format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
246+ format: "hh:mm - MMM dd"
247+ }
248+
249+ text: menuData && menuData.label || ""
250+ iconSource: menuData && menuData.icon || "image://theme/calendar"
251+ time: timeFormatter.timeString
252+ eventColor: menu && menu.ext.hasOwnProperty("xCanonicalColor") ? menu.ext.xCanonicalColor : Qt.rgba(0.0, 0.0, 0.0, 0.0)
253+ enabled: menuData && menuData.sensitive || false
254+
255+ onMenuModelChanged: {
256+ loadAttributes();
257+ }
258+ onMenuIndexChanged: {
259+ loadAttributes();
260+ }
261+ onTriggered: {
262+ menuModel.activate(menuIndex);
263+ }
264+
265+ function loadAttributes() {
266+ if (!menuModel || menuIndex == -1) return;
267+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-color': 'string',
268+ 'x-canonical-time': 'int64',
269+ 'x-canonical-time-format': 'string'});
270+ }
271+ }
272+ }
273+
193274 Component {
194275 id: wifiSection;
195− Indicators.SectionMenuItem {
276+ Menus.SectionMenu {
196277 objectName: "wifiSection"
197278 property QtObject menuData: null
198279 property var menuModel: menuFactory.menuModel
@@ -210,7 +291,7 @@ Item {
210291 }
211292
212293 function loadAttributes() {
213− if (!menuModel || menuIndex == undefined) return;
294+ if (!menuModel || menuIndex == -1) return;
214295 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'})
215296 }
216297 }
@@ -218,7 +299,7 @@ Item {
218299
219300 Component {
220301 id: accessPoint;
221− ICNetwork.AccessPoint {
302+ Menus.AccessPointMenu {
222303 objectName: "accessPoint"
223304 property QtObject menuData: null
224305 property var menuModel: menuFactory.menuModel
@@ -231,11 +312,11 @@ Item {
231312 name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
232313 }
233314
234− label: menuData && menuData.label || ""
315+ text: menuData && menuData.label || ""
235316 enabled: menuData && menuData.sensitive || false
317+ checked: menuData && menuData.isToggled || false
236318 secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
237319 adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
238− checked: menuData ? menuData.isToggled : false
239320 signalStrength: strengthAction.valid ? strengthAction.state : 0
240321
241322 onMenuModelChanged: {
@@ -244,13 +325,13 @@ Item {
244325 onMenuIndexChanged: {
245326 loadAttributes();
246327 }
247− onActivate: {
328+ onTriggered: {
248329 menuModel.activate(menuIndex);
249330 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
250331 }
251332
252333 function loadAttributes() {
253− if (!menuModel || menuIndex == undefined) return;
334+ if (!menuModel || menuIndex == -1) return;
254335 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
255336 'x-canonical-wifi-ap-is-secure': 'bool',
256337 'x-canonical-wifi-ap-strength-action': 'string'});
@@ -260,7 +341,7 @@ Item {
260341
261342 Component {
262343 id: messageItem
263− ICMessaging.MessageMenuItemFactory {
344+ MessageMenuItemFactory {
264345 objectName: "messageItem"
265346 menuModel: menuFactory.menuModel
266347 }
@@ -268,17 +349,18 @@ Item {
268349
269350 Component {
270351 id: groupedMessage
271− ICMessaging.GroupedMessage {
352+ Menus.GroupedMessageMenu {
272353 objectName: "groupedMessage"
273354 property QtObject menuData: null
274355 property var menuModel: menuFactory.menuModel
275356 property int menuIndex: -1
276357 property var extendedData: menuData && menuData.ext || undefined
277358
278− title: menuData && menuData.label || ""
279− appIcon: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_app.svg")
359+ text: menuData && menuData.label || ""
360+ icon: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_app.svg")
280361 count: menuData && menuData.actionState.length > 0 ? menuData.actionState[0] : "0"
281362 enabled: menuData && menuData.sensitive || false
363+ removable: true
282364
283365 onMenuModelChanged: {
284366 loadAttributes();
@@ -286,21 +368,98 @@ Item {
286368 onMenuIndexChanged: {
287369 loadAttributes();
288370 }
289− onActivateApp: {
371+ onClicked: {
290372 menuModel.activate(menuIndex, true);
291373 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
292374 }
293− onDismiss: {
375+ onDismissed: {
294376 menuModel.activate(menuIndex, false);
295377 }
296378
297379 function loadAttributes() {
298− if (!menuModel || menuIndex == undefined) return;
380+ if (!menuModel || menuIndex == -1) return;
299381 menuModel.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
300382 }
301383 }
302384 }
303385
386+ Component {
387+ id: mediaPayerMenu;
388+ Menus.MediaPlayerMenu {
389+ property QtObject menuData: null
390+ property var menuModel: menuFactory.menuModel
391+ property int menuIndex: -1
392+ property var actionState: menuData && menuData.actionState || undefined
393+
394+ playerIcon: menuData && menuData.icon || ""
395+ playerName: menuData && menuData.label || ""
396+
397+ albumArt: getExtendedProperty(actionState, "art-url", "")
398+ song: getExtendedProperty(actionState, "title", "unknown")
399+ artist: getExtendedProperty(actionState, "artist", "unknown")
400+ album: getExtendedProperty(actionState, "album", "unknown")
401+ running: getExtendedProperty(actionState, "running", false)
402+ state: getExtendedProperty(actionState, "state", "")
403+
404+ onTriggered: {
405+ model.activate(modelIndex);
406+ }
407+ }
408+ }
409+
410+ Component {
411+ id: playbackItemMenu;
412+ Menus.PlaybackItemMenu {
413+ property var menuModel: menuFactory.menuModel
414+ property int menuIndex: -1
415+ property var extendedData: menuData && menuData.ext || undefined
416+
417+ property var playAction: QMenuModel.UnityMenuAction {
418+ model: menuModel
419+ index: menuIndex
420+ name: getExtendedProperty(extendedData, "xCanonicalPlayAction", "")
421+ }
422+ property var nextAction: QMenuModel.UnityMenuAction {
423+ model: menuModel
424+ index: menuIndex
425+ name: getExtendedProperty(extendedData, "xCanonicalNextAction", "")
426+ }
427+ property var previousAction: QMenuModel.UnityMenuAction {
428+ model: menuModel
429+ index: menuIndex
430+ name: getExtendedProperty(extendedData, "xCanonicalPreviousAction", "")
431+ }
432+
433+ playing: playAction.state === "Playing"
434+ canPlay: playAction.valid
435+ canGoNext: nextAction.valid
436+ canGoPrevious: previousAction.valid
437+
438+ onPlay: {
439+ playAction.activate();
440+ }
441+ onNext: {
442+ nextAction.activate();
443+ }
444+ onPrevious: {
445+ previousAction.activate();
446+ }
447+ onMenuModelChanged: {
448+ loadAttributes();
449+ }
450+ onMenuIndexChanged: {
451+ loadAttributes();
452+ }
453+
454+ function loadAttributes() {
455+ if (!menuModel || menuIndex == -1) return;
456+ menuModel.loadExtendedAttributes(modelIndex, {'x-canonical-play-action': 'string',
457+ 'x-canonical-next-action': 'string',
458+ 'x-canonical-previous-action': 'string'});
459+ }
460+ }
461+ }
462+
304463 function load(modelData) {
305464 if (modelData.type !== undefined) {
306465 var component = _map[modelData.type];
@@ -309,7 +468,7 @@ Item {
309468 }
310469 }
311470 if (modelData.isSeparator) {
312− return divMenu;
471+ return separatorMenu;
313472 }
314473 return standardMenu;
315474 }