2 * Copyright 2013 Canonical Ltd.
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
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Nick Dedekind <nick.dedekind@canonical.com>
21import Ubuntu.Settings.Menus 0.1 as Menus
22import QMenuModel 0.1 as QMenuModel
23import Utils 0.1 as Utils
24import Ubuntu.Components.ListItems 0.1 as ListItems
25import Ubuntu.Components 0.1
30 property var menuModel: null
33 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
34 "unity.widgets.systemsettings.tablet.switch" : switchMenu,
36 "com.canonical.indicator.button" : buttonMenu,
37 "com.canonical.indicator.div" : separatorMenu,
38 "com.canonical.indicator.section" : sectionMenu,
39 "com.canonical.indicator.progress" : progressMenu,
40 "com.canonical.indicator.slider" : sliderMenu,
41 "com.canonical.indicator.switch" : switchMenu,
42 "com.canonical.indicator.alarm" : alarmMenu,
43 "com.canonical.indicator.appointment" : appointmentMenu,
45 "com.canonical.indicator.messages.messageitem" : messageItem,
46 "com.canonical.indicator.messages.sourceitem" : groupedMessage,
48 "com.canonical.unity.slider" : sliderMenu,
49 "com.canonical.unity.switch" : switchMenu,
51 "com.canonical.unity.media-player" : mediaPayerMenu,
52 "com.canonical.unity.playback-item" : playbackItemMenu,
54 "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
55 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
56 "com.canonical.indicator.network.modeminfoitem" : modeminfoitem,
59 function getExtendedProperty(object, propertyName, defaultValue) {
60 if (object && object.hasOwnProperty(propertyName)) {
61 return object[propertyName];
69 objectName: "separatorMenu"
76 objectName: "sliderMenu"
77 property QtObject menuData: null
78 property var menuModel: menuFactory.menuModel
79 property int menuIndex: -1
80 property var extendedData: menuData && menuData.ext || undefined
81 property var serverValue: getExtendedProperty(menuData, "actionState", undefined)
83 text: menuData && menuData.label || ""
84 iconSource: menuData && menuData.icon || ""
85 minIcon: getExtendedProperty(extendedData, "minIcon", "")
86 maxIcon: getExtendedProperty(extendedData, "maxIcon", "")
88 minimumValue: getExtendedProperty(extendedData, "minValue", 0.0)
90 var maximum = getExtendedProperty(extendedData, "maxValue", 1.0);
91 if (maximum <= minimumValue) {
92 return minimumValue + 1;
96 enabled: menuData && menuData.sensitive || false
101 onMenuIndexChanged: {
104 onServerValueChanged: {
105 // value can be changed by slider, so a binding won't work.
106 if (serverValue !== undefined) {
111 menuModel.changeState(menuIndex, value);
114 function loadAttributes() {
115 if (!menuModel || menuIndex == -1) return;
116 menuModel.loadExtendedAttributes(menuIndex, {'min-value': 'double',
117 'max-value': 'double',
119 'max-icon': 'icon'});
127 objectName: "buttonMenu"
128 property QtObject menuData: null
129 property var menuModel: menuFactory.menuModel
130 property int menuIndex: -1
132 buttonText: menuData && menuData.label || ""
133 enabled: menuData && menuData.sensitive || false
136 menuModel.activate(menuIndex);
137 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
144 objectName: "sectionMenu"
145 property QtObject menuData: null
146 property var menuIndex: undefined
148 text: menuData && menuData.label || ""
155 Menus.ProgressValueMenu {
156 objectName: "progressMenu"
157 property QtObject menuData: null
158 property int menuIndex: -1
160 text: menuData && menuData.label || ""
161 iconSource: menuData && menuData.icon || ""
162 value : menuData && menuData.actionState || 0.0
163 enabled: menuData && menuData.sensitive || false
170 objectName: "standardMenu"
171 property QtObject menuData: null
172 property int menuIndex: -1
174 text: menuData && menuData.label || ""
175 iconSource: menuData && menuData.icon || ""
176 enabled: menuData && menuData.sensitive || false
179 menuModel.activate(menuIndex);
180 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
187 Menus.CheckableMenu {
188 objectName: "checkableMenu"
189 property QtObject menuData: null
190 property int menuIndex: -1
192 text: menuData && menuData.label || ""
193 enabled: menuData && menuData.sensitive || false
194 checked: menuData && menuData.isToggled || false
197 menuModel.activate(menuIndex);
198 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
207 objectName: "switchMenu"
208 property QtObject menuData: null
209 property int menuIndex: -1
211 text: menuData && menuData.label || ""
212 iconSource: menuData && menuData.icon || ""
213 enabled: menuData && menuData.sensitive || false
214 checked: menuData && menuData.isToggled || false
217 menuModel.activate(menuIndex);
218 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
226 objectName: "alarmMenu"
227 property QtObject menuData: null
228 property var menuModel: menuFactory.menuModel
229 property int menuIndex: -1
230 property var extendedData: menuData && menuData.ext || undefined
231 // TODO - bug #1260728
232 property var timeFormatter: Utils.GDateTimeFormatter {
233 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
234 format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
237 text: menuData && menuData.label || ""
238 iconSource: menuData && menuData.icon || "image://theme/alarm-clock"
239 time: timeFormatter.timeString
240 enabled: menuData && menuData.sensitive || false
242 onMenuModelChanged: {
245 onMenuIndexChanged: {
249 menuModel.activate(menuIndex);
252 function loadAttributes() {
253 if (!menuModel || menuIndex == -1) return;
254 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-time': 'int64',
255 'x-canonical-time-format': 'string'});
263 objectName: "appointmentMenu"
264 property QtObject menuData: null
265 property var menuModel: menuFactory.menuModel
266 property int menuIndex: -1
267 property var extendedData: menuData && menuData.ext || undefined
268 // TODO - bug #1260728
269 property var timeFormatter: Utils.GDateTimeFormatter {
270 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
271 format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
274 text: menuData && menuData.label || ""
275 iconSource: menuData && menuData.icon || "image://theme/calendar"
276 time: timeFormatter.timeString
277 eventColor: getExtendedProperty(extendedData, "xCanonicalColor", Qt.rgba(0.0, 0.0, 0.0, 0.0))
278 enabled: menuData && menuData.sensitive || false
280 onMenuModelChanged: {
283 onMenuIndexChanged: {
287 menuModel.activate(menuIndex);
290 function loadAttributes() {
291 if (!menuModel || menuIndex == -1) return;
292 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-color': 'string',
293 'x-canonical-time': 'int64',
294 'x-canonical-time-format': 'string'});
302 objectName: "wifiSection"
303 property QtObject menuData: null
304 property var menuModel: menuFactory.menuModel
305 property int menuIndex: -1
306 property var extendedData: menuData && menuData.ext || undefined
308 text: menuData && menuData.label || ""
309 busy: getExtendedProperty(extendedData, "xCanonicalBusyAction", false)
311 onMenuModelChanged: {
314 onMenuIndexChanged: {
318 function loadAttributes() {
319 if (!menuModel || menuIndex == -1) return;
320 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'})
327 Menus.AccessPointMenu {
328 objectName: "accessPoint"
329 property QtObject menuData: null
330 property var menuModel: menuFactory.menuModel
331 property int menuIndex: -1
332 property var extendedData: menuData && menuData.ext || undefined
334 property var strengthAction: QMenuModel.UnityMenuAction {
337 name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
340 text: menuData && menuData.label || ""
341 enabled: menuData && menuData.sensitive || false
342 checked: menuData && menuData.isToggled || false
343 secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
344 adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
345 signalStrength: strengthAction.valid ? strengthAction.state : 0
347 onMenuModelChanged: {
350 onMenuIndexChanged: {
354 menuModel.activate(menuIndex);
355 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
358 function loadAttributes() {
359 if (!menuModel || menuIndex == -1) return;
360 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
361 'x-canonical-wifi-ap-is-secure': 'bool',
362 'x-canonical-wifi-ap-strength-action': 'string'});
370 objectName: "modemInfoItem"
371 property QtObject menuData: null
372 property var menuModel: menuFactory.menuModel
373 property int menuIndex: -1
374 property var extendedData: menuData && menuData.ext || undefined
376 property var statusLabelAction: QMenuModel.UnityMenuAction {
379 name: getExtendedProperty(extendedData, "xCanonicalModemStatusLabelAction", "")
381 statusText: statusLabelAction.valid ? statusLabelAction.state : ""
383 property var statusIconAction: QMenuModel.UnityMenuAction {
386 name: getExtendedProperty(extendedData, "xCanonicalModemStatusIconAction", "")
388 statusIcon: statusIconAction.valid ? statusIconAction.state : ""
390 property var connectivityIconAction: QMenuModel.UnityMenuAction {
393 name: getExtendedProperty(extendedData, "xCanonicalModemConnectivityIconAction", "")
395 connectivityIcon: connectivityIconAction.valid ? connectivityIconAction.state : ""
397 property var simIdentifierLabelAction: QMenuModel.UnityMenuAction {
400 name: getExtendedProperty(extendedData, "xCanonicalModemSimIdentifierLabelAction", "")
402 simIdentifierText: simIdentifierLabelAction.valid ? simIdentifierLabelAction.state : ""
404 property var roamingAction: QMenuModel.UnityMenuAction {
407 name: getExtendedProperty(extendedData, "xCanonicalModemRoamingAction", "")
409 roaming: roamingAction.valid ? roamingAction.state : false
411 property var unlockAction: QMenuModel.UnityMenuAction {
414 name: getExtendedProperty(extendedData, "xCanonicalModemLockedAction", "")
417 unlockAction.activate();
418 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
420 locked: unlockAction.valid ? unlockAction.state : false
422 onMenuModelChanged: {
425 onMenuIndexChanged: {
429 function loadAttributes() {
430 if (!menuModel || menuIndex == -1) return;
431 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-modem-status-label-action': 'string',
432 'x-canonical-modem-status-icon-action': 'string',
433 'x-canonical-modem-connectivity-icon-action': 'string',
434 'x-canonical-modem-sim-identifier-label': 'string',
435 'x-canonical-modem-roaming-action': 'string',
436 'x-canonical-modem-locked-action': 'string'});
443 MessageMenuItemFactory {
444 objectName: "messageItem"
445 menuModel: menuFactory.menuModel
451 Menus.GroupedMessageMenu {
452 objectName: "groupedMessage"
453 property QtObject menuData: null
454 property var menuModel: menuFactory.menuModel
455 property int menuIndex: -1
456 property var extendedData: menuData && menuData.ext || undefined
458 text: menuData && menuData.label || ""
459 iconSource: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_app.svg")
460 count: menuData && menuData.actionState.length > 0 ? menuData.actionState[0] : "0"
461 enabled: menuData && menuData.sensitive || false
464 onMenuModelChanged: {
467 onMenuIndexChanged: {
471 menuModel.activate(menuIndex, true);
472 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
475 menuModel.activate(menuIndex, false);
478 function loadAttributes() {
479 if (!menuModel || menuIndex == -1) return;
480 menuModel.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
487 Menus.MediaPlayerMenu {
488 objectName: "mediaPayerMenu"
489 property QtObject menuData: null
490 property var menuModel: menuFactory.menuModel
491 property int menuIndex: -1
492 property var actionState: menuData && menuData.actionState || undefined
494 playerIcon: menuData && menuData.icon || ""
495 playerName: menuData && menuData.label || ""
497 albumArt: getExtendedProperty(actionState, "art-url", "")
498 song: getExtendedProperty(actionState, "title", "unknown")
499 artist: getExtendedProperty(actionState, "artist", "unknown")
500 album: getExtendedProperty(actionState, "album", "unknown")
501 running: getExtendedProperty(actionState, "running", false)
502 state: getExtendedProperty(actionState, "state", "")
503 enabled: menuData && menuData.sensitive || false
506 model.activate(modelIndex);
512 id: playbackItemMenu;
513 Menus.PlaybackItemMenu {
514 objectName: "playbackItemMenu"
515 property QtObject menuData: null
516 property var menuModel: menuFactory.menuModel
517 property int menuIndex: -1
518 property var extendedData: menuData && menuData.ext || undefined
520 property var playAction: QMenuModel.UnityMenuAction {
523 name: getExtendedProperty(extendedData, "xCanonicalPlayAction", "")
525 property var nextAction: QMenuModel.UnityMenuAction {
528 name: getExtendedProperty(extendedData, "xCanonicalNextAction", "")
530 property var previousAction: QMenuModel.UnityMenuAction {
533 name: getExtendedProperty(extendedData, "xCanonicalPreviousAction", "")
536 playing: playAction.state === "Playing"
537 canPlay: playAction.valid
538 canGoNext: nextAction.valid
539 canGoPrevious: previousAction.valid
540 enabled: menuData && menuData.sensitive || false
543 playAction.activate();
546 nextAction.activate();
549 previousAction.activate();
551 onMenuModelChanged: {
554 onMenuIndexChanged: {
558 function loadAttributes() {
559 if (!menuModel || menuIndex == -1) return;
560 menuModel.loadExtendedAttributes(modelIndex, {'x-canonical-play-action': 'string',
561 'x-canonical-next-action': 'string',
562 'x-canonical-previous-action': 'string'});
567 function load(modelData) {
568 if (modelData.type !== undefined) {
569 var component = _map[modelData.type];
570 if (component !== undefined) {
574 if (modelData.isCheck || modelData.isRadio) {
575 return checkableMenu;
577 if (modelData.isSeparator) {
578 return separatorMenu;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list