2 * Copyright 2013,2015 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/>.
18 import QtQuick.Window 2.2
19 import Ubuntu.Settings.Menus 0.1 as Menus
20 import Ubuntu.Settings.Components 0.1
22 import Utils 0.1 as Utils
23 import Ubuntu.Components.ListItems 1.3 as ListItems
24 import Ubuntu.Components 1.3
25 import Unity.Session 0.1
26 import Unity.Platform 1.0
31 property var rootModel: null
32 property var menuModel: null
36 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
37 "unity.widgets.systemsettings.tablet.switch" : switchMenu,
39 "com.canonical.indicator.button" : buttonMenu,
40 "com.canonical.indicator.div" : separatorMenu,
41 "com.canonical.indicator.section" : sectionMenu,
42 "com.canonical.indicator.progress" : progressMenu,
43 "com.canonical.indicator.slider" : sliderMenu,
44 "com.canonical.indicator.switch" : switchMenu,
45 "com.canonical.indicator.alarm" : alarmMenu,
46 "com.canonical.indicator.appointment" : appointmentMenu,
47 "com.canonical.indicator.transfer" : transferMenu,
48 "com.canonical.indicator.button-section" : buttonSectionMenu,
49 "com.canonical.indicator.link" : linkMenu,
51 "com.canonical.indicator.messages.messageitem" : messageItem,
52 "com.canonical.indicator.messages.sourceitem" : groupedMessage,
54 "com.canonical.unity.slider" : sliderMenu,
55 "com.canonical.unity.switch" : switchMenu,
57 "com.canonical.unity.media-player" : mediaPayerMenu,
58 "com.canonical.unity.playback-item" : playbackItemMenu,
60 "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
61 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
62 "com.canonical.indicator.network.modeminfoitem" : modeminfoitem,
64 "com.canonical.indicator.calendar": calendarMenu,
65 "com.canonical.indicator.location": timezoneMenu,
67 "indicator-session": {
68 "indicator.user-menu-item": Platform.isPC ? userMenuItem : null,
69 "indicator.guest-menu-item": Platform.isPC ? userMenuItem : null,
70 "com.canonical.indicator.switch": Math.min(Screen.width, Screen.height) > units.gu(60) ? switchMenu : null // Desktop mode switch
72 "indicator-messages" : {
73 "com.canonical.indicator.button" : messagesButtonMenu
77 function getExtendedProperty(object, propertyName, defaultValue) {
78 if (object && object.hasOwnProperty(propertyName)) {
79 return object[propertyName];
88 objectName: "separatorMenu"
97 objectName: "sliderMenu"
98 property QtObject menuData: null
99 property var menuModel: menuFactory.menuModel
100 property int menuIndex: -1
101 property var extendedData: menuData && menuData.ext || undefined
102 property var serverValue: getExtendedProperty(menuData, "actionState", undefined)
104 text: menuData && menuData.label || ""
105 iconSource: menuData && menuData.icon || ""
106 minIcon: getExtendedProperty(extendedData, "minIcon", "")
107 maxIcon: getExtendedProperty(extendedData, "maxIcon", "")
109 minimumValue: getExtendedProperty(extendedData, "minValue", 0.0)
111 var maximum = getExtendedProperty(extendedData, "maxValue", 1.0);
112 if (maximum <= minimumValue) {
113 return minimumValue + 1;
117 enabled: menuData && menuData.sensitive || false
118 highlightWhenPressed: false
120 onMenuModelChanged: {
123 onMenuIndexChanged: {
127 function loadAttributes() {
128 if (!menuModel || menuIndex == -1) return;
129 menuModel.loadExtendedAttributes(menuIndex, {'min-value': 'double',
130 'max-value': 'double',
133 'x-canonical-sync-action': 'string'});
136 ServerPropertySynchroniser {
137 id: sliderPropertySync
139 syncTimeout: Utils.Constants.indicatorValueTimeout
140 bufferedSyncTimeout: true
141 maximumWaitBufferInterval: 16
143 serverTarget: sliderItem
144 serverProperty: "serverValue"
145 userTarget: sliderItem
146 userProperty: "value"
148 onSyncTriggered: menuModel.changeState(menuIndex, value)
154 name: getExtendedProperty(extendedData, "xCanonicalSyncAction", "")
156 sliderPropertySync.reset();
157 sliderPropertySync.updateUserValue();
167 objectName: "buttonMenu"
168 property QtObject menuData: null
169 property var menuModel: menuFactory.menuModel
170 property int menuIndex: -1
172 buttonText: menuData && menuData.label || ""
173 enabled: menuData && menuData.sensitive || false
174 highlightWhenPressed: false
177 menuModel.activate(menuIndex);
183 id: messagesButtonMenu;
186 objectName: "messagesButtonMenu"
187 property QtObject menuData: null
188 property var menuModel: menuFactory.menuModel
189 property int menuIndex: -1
191 implicitHeight: units.gu(5)
192 enabled: menuData && menuData.sensitive || false
196 text: menuData && menuData.label || ""
197 anchors.centerIn: parent
203 fill: buttonMenuLabel
204 margins: units.gu(-1)
206 onClicked: menuModel.activate(menuIndex);
215 objectName: "sectionMenu"
216 property QtObject menuData: null
217 property var menuIndex: undefined
219 text: menuData && menuData.label || ""
227 Menus.ProgressValueMenu {
228 objectName: "progressMenu"
229 property QtObject menuData: null
230 property int menuIndex: -1
232 text: menuData && menuData.label || ""
233 iconSource: menuData && menuData.icon || ""
234 value : menuData && menuData.actionState || 0.0
235 enabled: menuData && menuData.sensitive || false
236 // FIXME: Because of this bug, setting it to the theme foreground color (white)
237 // currently doesn't work. Let's hack it to be "close enough"
238 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1555784
239 foregroundColor: "#fffffe"
240 highlightWhenPressed: false
248 objectName: "standardMenu"
249 property QtObject menuData: null
250 property int menuIndex: -1
252 text: menuData && menuData.label || ""
253 iconSource: menuData && menuData.icon || ""
254 enabled: menuData && menuData.sensitive || false
255 highlightWhenPressed: false
258 menuModel.activate(menuIndex);
261 // FIXME : At the moment, the indicators aren't using
262 // com.canonical.indicators.link for settings menu. Need to fudge it.
263 property bool settingsMenu: menuData && menuData.action.indexOf("settings") > -1 || false
264 backColor: settingsMenu ? Qt.rgba(1,1,1,0.07) : "transparent"
265 component: settingsMenu ? buttonForSettings : undefined
267 id: buttonForSettings
272 color: theme.palette.normal.backgroundText
282 objectName: "linkMenu"
283 property QtObject menuData: null
284 property int menuIndex: -1
286 text: menuData && menuData.label || ""
287 iconSource: menuData && menuData.icon || ""
288 enabled: menuData && menuData.sensitive || false
289 highlightWhenPressed: false
292 menuModel.activate(menuIndex);
295 backColor: Qt.rgba(1,1,1,0.07)
297 component: menuData.icon ? icon : undefined
301 source: menuData.icon
304 color: theme.palette.normal.backgroundText
313 Menus.CheckableMenu {
315 objectName: "checkableMenu"
316 property QtObject menuData: null
317 property int menuIndex: -1
318 property bool serverChecked: menuData && menuData.isToggled || false
320 text: menuData && menuData.label || ""
321 enabled: menuData && menuData.sensitive || false
322 checked: serverChecked
323 highlightWhenPressed: false
325 ServerPropertySynchroniser {
327 syncTimeout: Utils.Constants.indicatorValueTimeout
329 serverTarget: checkItem
330 serverProperty: "serverChecked"
331 userTarget: checkItem
332 userProperty: "checked"
334 onSyncTriggered: menuModel.activate(checkItem.menuIndex)
344 objectName: "switchMenu"
345 property QtObject menuData: null
346 property int menuIndex: -1
347 property bool serverChecked: menuData && menuData.isToggled || false
349 text: menuData && menuData.label || ""
350 iconSource: menuData && menuData.icon || ""
351 enabled: menuData && menuData.sensitive || false
352 checked: serverChecked
353 highlightWhenPressed: false
355 ServerPropertySynchroniser {
357 syncTimeout: Utils.Constants.indicatorValueTimeout
359 serverTarget: switchItem
360 serverProperty: "serverChecked"
361 userTarget: switchItem
362 userProperty: "checked"
364 onSyncTriggered: menuModel.activate(switchItem.menuIndex);
374 objectName: "alarmMenu"
375 property QtObject menuData: null
376 property var menuModel: menuFactory.menuModel
377 property int menuIndex: -1
378 property var extendedData: menuData && menuData.ext || undefined
380 readonly property date serverTime: new Date(getExtendedProperty(extendedData, "xCanonicalTime", 0) * 1000)
382 frequency: LiveTimer.Relative
383 relativeTime: alarmItem.serverTime
384 onTrigger: alarmItem.time = i18n.relativeDateTime(alarmItem.serverTime)
387 text: menuData && menuData.label || ""
388 iconSource: menuData && menuData.icon || "image://theme/alarm-clock"
389 time: i18n.relativeDateTime(serverTime)
390 enabled: menuData && menuData.sensitive || false
391 highlightWhenPressed: false
393 onMenuModelChanged: {
396 onMenuIndexChanged: {
400 menuModel.activate(menuIndex);
403 function loadAttributes() {
404 if (!menuModel || menuIndex == -1) return;
405 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-time': 'int64'});
415 objectName: "appointmentMenu"
416 property QtObject menuData: null
417 property var menuModel: menuFactory.menuModel
418 property int menuIndex: -1
419 property var extendedData: menuData && menuData.ext || undefined
421 readonly property date serverTime: new Date(getExtendedProperty(extendedData, "xCanonicalTime", 0) * 1000)
424 frequency: LiveTimer.Relative
425 relativeTime: appointmentItem.serverTime
426 onTrigger: appointmentItem.time = i18n.relativeDateTime(appointmentItem.serverTime)
429 text: menuData && menuData.label || ""
430 iconSource: menuData && menuData.icon || "image://theme/calendar"
431 time: i18n.relativeDateTime(serverTime)
432 eventColor: getExtendedProperty(extendedData, "xCanonicalColor", Qt.rgba(0.0, 0.0, 0.0, 0.0))
433 enabled: menuData && menuData.sensitive || false
434 highlightWhenPressed: false
436 onMenuModelChanged: {
439 onMenuIndexChanged: {
443 menuModel.activate(menuIndex);
446 function loadAttributes() {
447 if (!menuModel || menuIndex == -1) return;
448 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-color': 'string',
449 'x-canonical-time': 'int64'});
457 Menus.UserSessionMenu {
458 objectName: "userSessionMenu"
459 highlightWhenPressed: false
461 property QtObject menuData: null
462 property var menuModel: menuFactory.menuModel
463 property int menuIndex: -1
465 name: menuData && menuData.label || "" // label is the user's real name
466 iconSource: menuData && menuData.icon || ""
468 // would be better to compare with the logname but sadly the indicator doesn't expose that
469 active: DBusUnitySessionService.RealName() !== "" ? DBusUnitySessionService.RealName() == name
470 : DBusUnitySessionService.UserName() == name
473 menuModel.activate(menuIndex);
482 objectName: "calendarMenu"
483 highlightWhenPressed: false
493 objectName: "timezoneMenu"
495 property QtObject menuData: null
496 property var menuModel: menuFactory.menuModel
497 property int menuIndex: -1
498 property var extendedData: menuData && menuData.ext || undefined
499 readonly property string tz: getExtendedProperty(extendedData, "xCanonicalTimezone", "UTC")
500 property var updateTimer: Timer {
502 running: tzMenuItem.visible // only run when we're open
503 onTriggered: tzMenuItem.time = Utils.TimezoneFormatter.currentTimeInTimezone(tzMenuItem.tz)
506 city: menuData && menuData.label || ""
507 time: Utils.TimezoneFormatter.currentTimeInTimezone(tz)
508 enabled: menuData && menuData.sensitive || false
510 onMenuModelChanged: {
513 onMenuIndexChanged: {
517 tzActionGroup.setLocation.activate(tz);
522 busType: DBus.SessionBus
523 busName: "com.canonical.indicator.datetime"
524 objectPath: "/com/canonical/indicator/datetime"
526 property variant setLocation: action("set-location")
528 Component.onCompleted: tzActionGroup.start()
531 function loadAttributes() {
532 if (!menuModel || menuIndex == -1) return;
533 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-timezone': 'string'});
542 objectName: "wifiSection"
543 property QtObject menuData: null
544 property var menuModel: menuFactory.menuModel
545 property int menuIndex: -1
546 property var extendedData: menuData && menuData.ext || undefined
548 text: menuData && menuData.label || ""
549 busy: getExtendedProperty(extendedData, "xCanonicalBusyAction", false)
551 onMenuModelChanged: {
554 onMenuIndexChanged: {
558 function loadAttributes() {
559 if (!menuModel || menuIndex == -1) return;
560 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'})
568 Menus.AccessPointMenu {
570 objectName: "accessPoint"
571 property QtObject menuData: null
572 property var menuModel: menuFactory.menuModel
573 property int menuIndex: -1
574 property var extendedData: menuData && menuData.ext || undefined
575 property bool serverChecked: menuData && menuData.isToggled || false
577 property var strengthAction: UnityMenuAction {
580 name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
583 text: menuData && menuData.label || ""
584 enabled: menuData && menuData.sensitive || false
585 active: serverChecked
586 secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
587 adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
589 if (strengthAction.valid) {
590 var state = strengthAction.state; // handle both int and uchar
591 // FIXME remove the special casing when we switch to indicator-network completely
592 if (typeof state == "string") {
593 return state.charCodeAt();
599 highlightWhenPressed: false
601 onMenuModelChanged: {
604 onMenuIndexChanged: {
608 function loadAttributes() {
609 if (!menuModel || menuIndex == -1) return;
610 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
611 'x-canonical-wifi-ap-is-secure': 'bool',
612 'x-canonical-wifi-ap-strength-action': 'string'});
615 ServerPropertySynchroniser {
617 syncTimeout: Utils.Constants.indicatorValueTimeout
620 serverProperty: "serverChecked"
622 userProperty: "active"
623 userTrigger: "onTriggered"
625 onSyncTriggered: menuModel.activate(apItem.menuIndex)
632 Menus.ModemInfoItem {
633 objectName: "modemInfoItem"
634 property QtObject menuData: null
635 property var menuModel: menuFactory.menuModel
636 property int menuIndex: -1
637 property var extendedData: menuData && menuData.ext || undefined
638 highlightWhenPressed: false
640 property var statusLabelAction: UnityMenuAction {
643 name: getExtendedProperty(extendedData, "xCanonicalModemStatusLabelAction", "")
645 statusText: statusLabelAction.valid ? statusLabelAction.state : ""
647 property var statusIconAction: UnityMenuAction {
650 name: getExtendedProperty(extendedData, "xCanonicalModemStatusIconAction", "")
652 statusIcon: statusIconAction.valid ? statusIconAction.state : ""
654 property var connectivityIconAction: UnityMenuAction {
657 name: getExtendedProperty(extendedData, "xCanonicalModemConnectivityIconAction", "")
659 connectivityIcon: connectivityIconAction.valid ? connectivityIconAction.state : ""
661 property var simIdentifierLabelAction: UnityMenuAction {
664 name: getExtendedProperty(extendedData, "xCanonicalModemSimIdentifierLabelAction", "")
666 simIdentifierText: simIdentifierLabelAction.valid ? simIdentifierLabelAction.state : ""
668 property var roamingAction: UnityMenuAction {
671 name: getExtendedProperty(extendedData, "xCanonicalModemRoamingAction", "")
673 roaming: roamingAction.valid ? roamingAction.state : false
675 property var unlockAction: UnityMenuAction {
678 name: getExtendedProperty(extendedData, "xCanonicalModemLockedAction", "")
681 unlockAction.activate();
683 locked: unlockAction.valid ? unlockAction.state : false
685 onMenuModelChanged: {
688 onMenuIndexChanged: {
692 function loadAttributes() {
693 if (!menuModel || menuIndex == -1) return;
694 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-modem-status-label-action': 'string',
695 'x-canonical-modem-status-icon-action': 'string',
696 'x-canonical-modem-connectivity-icon-action': 'string',
697 'x-canonical-modem-sim-identifier-label-action': 'string',
698 'x-canonical-modem-roaming-action': 'string',
699 'x-canonical-modem-locked-action': 'string'});
707 MessageMenuItemFactory {
708 objectName: "messageItem"
709 menuModel: menuFactory.menuModel
716 Menus.GroupedMessageMenu {
717 objectName: "groupedMessage"
718 property QtObject menuData: null
719 property var menuModel: menuFactory.menuModel
720 property int menuIndex: -1
721 property var extendedData: menuData && menuData.ext || undefined
723 text: menuData && menuData.label || ""
724 iconSource: getExtendedProperty(extendedData, "icon", "image://theme/message")
725 count: menuData && menuData.actionState.length > 0 ? menuData.actionState[0] : "0"
726 enabled: menuData && menuData.sensitive || false
727 highlightWhenPressed: false
730 onMenuModelChanged: {
733 onMenuIndexChanged: {
737 menuModel.activate(menuIndex, true);
740 menuModel.activate(menuIndex, false);
743 function loadAttributes() {
744 if (!menuModel || menuIndex == -1) return;
745 menuModel.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
753 Menus.MediaPlayerMenu {
754 objectName: "mediaPayerMenu"
755 property QtObject menuData: null
756 property var menuModel: menuFactory.menuModel
757 property int menuIndex: -1
758 property var actionState: menuData && menuData.actionState || undefined
759 property bool running: getExtendedProperty(actionState, "running", false)
761 playerIcon: menuData && menuData.icon || "image://theme/stock_music"
762 playerName: menuData && menuData.label || i18n.tr("Nothing is playing")
764 albumArt: getExtendedProperty(actionState, "art-url", "image://theme/stock_music")
765 song: getExtendedProperty(actionState, "title", "")
766 artist: getExtendedProperty(actionState, "artist", "")
767 album: getExtendedProperty(actionState, "album", "")
768 showTrack: running && (state == "Playing" || state == "Paused")
769 state: getExtendedProperty(actionState, "state", "")
770 enabled: menuData && menuData.sensitive || false
771 highlightWhenPressed: false
775 model.activate(modelIndex);
781 id: playbackItemMenu;
783 Menus.PlaybackItemMenu {
784 objectName: "playbackItemMenu"
785 property QtObject menuData: null
786 property var menuModel: menuFactory.menuModel
787 property int menuIndex: -1
788 property var extendedData: menuData && menuData.ext || undefined
790 property var playAction: UnityMenuAction {
793 name: getExtendedProperty(extendedData, "xCanonicalPlayAction", "")
795 property var nextAction: UnityMenuAction {
798 name: getExtendedProperty(extendedData, "xCanonicalNextAction", "")
800 property var previousAction: UnityMenuAction {
803 name: getExtendedProperty(extendedData, "xCanonicalPreviousAction", "")
806 playing: playAction.state === "Playing"
807 canPlay: playAction.valid
808 canGoNext: nextAction.valid
809 canGoPrevious: previousAction.valid
810 enabled: menuData && menuData.sensitive || false
811 highlightWhenPressed: false
814 playAction.activate();
817 nextAction.activate();
820 previousAction.activate();
822 onMenuModelChanged: {
825 onMenuIndexChanged: {
829 function loadAttributes() {
830 if (!menuModel || menuIndex == -1) return;
831 menuModel.loadExtendedAttributes(modelIndex, {'x-canonical-play-action': 'string',
832 'x-canonical-next-action': 'string',
833 'x-canonical-previous-action': 'string'});
842 objectName: "transferMenu"
844 property QtObject menuData: null
845 property var menuModel: menuFactory.menuModel
846 property int menuIndex: -1
847 property var extendedData: menuData && menuData.ext || undefined
848 property var uid: getExtendedProperty(extendedData, "xCanonicalUid", undefined)
850 text: menuData && menuData.label || ""
851 iconSource: menuData && menuData.icon || "image://theme/transfer-none"
853 enabled: menuData && menuData.sensitive || false
854 highlightWhenPressed: false
861 busName: rootModel.busName
862 objectPath: rootModel.actions["indicator"]
864 property var activateAction: action("activate-transfer")
865 property var cancelAction: action("cancel-transfer")
866 property var transferStateAction: uid !== undefined ? action("transfer-state."+uid) : null
868 Component.onCompleted: actionGroup.start()
871 property var transferState: {
872 if (actionGroup.transferStateAction === null) return undefined;
873 return actionGroup.transferStateAction.valid ? actionGroup.transferStateAction.state : undefined
876 property var runningState : transferState !== undefined ? transferState["state"] : undefined
877 property var secondsLeft : transferState !== undefined ? transferState["seconds-left"] : undefined
879 active: runningState !== undefined && runningState !== Menus.TransferState.Finished
880 progress: transferState !== undefined ? transferState["percent"] : 0.0
882 // TODO - Should be in the SDK
883 property var timeRemaining: {
884 if (secondsLeft === undefined) return undefined;
887 var hours = Math.floor(secondsLeft / (60 * 60));
888 var minutes = Math.floor(secondsLeft / 60) % 60;
889 var seconds = secondsLeft % 60;
891 remaining += i18n.tr("%1 hour", "%1 hours", hours).arg(hours)
894 if (remaining != "") remaining += ", ";
895 remaining += i18n.tr("%1 minute", "%1 minutes", minutes).arg(minutes)
897 // don't include seconds if hours > 0
898 if (hours == 0 && minutes < 5 && seconds > 0) {
899 if (remaining != "") remaining += ", ";
900 remaining += i18n.tr("%1 second", "%1 seconds", seconds).arg(seconds)
903 remaining = i18n.tr("0 seconds");
904 // Translators: String like "1 hour, 2 minutes, 3 seconds remaining"
905 return i18n.tr("%1 remaining").arg(remaining);
909 switch (runningState) {
910 case Menus.TransferState.Queued:
911 return i18n.tr("In queue…");
912 case Menus.TransferState.Hashing:
913 case Menus.TransferState.Processing:
914 case Menus.TransferState.Running:
915 return timeRemaining === undefined ? i18n.tr("Downloading") : timeRemaining;
916 case Menus.TransferState.Paused:
917 return i18n.tr("Paused, tap to resume");
918 case Menus.TransferState.Canceled:
919 return i18n.tr("Canceled");
920 case Menus.TransferState.Finished:
921 return i18n.tr("Finished");
922 case Menus.TransferState.Error:
923 return i18n.tr("Failed, tap to retry");
928 onMenuModelChanged: {
931 onMenuIndexChanged: {
935 actionGroup.activateAction.activate(uid);
938 actionGroup.cancelAction.activate(uid);
941 function loadAttributes() {
942 if (!menuModel || menuIndex == -1) return;
943 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-uid': 'string'});
949 id: buttonSectionMenu;
952 objectName: "buttonSectionMenu"
953 property QtObject menuData: null
954 property var menuModel: menuFactory.menuModel
955 property int menuIndex: -1
956 property var extendedData: menuData && menuData.ext || undefined
958 iconSource: menuData && menuData.icon || ""
959 enabled: menuData && menuData.sensitive || false
960 highlightWhenPressed: false
961 text: menuData && menuData.label || ""
962 foregroundColor: theme.palette.normal.backgroundText
964 onMenuModelChanged: {
967 onMenuIndexChanged: {
970 function loadAttributes() {
971 if (!menuModel || menuIndex == -1) return;
972 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-extra-label': 'string'});
975 component: Component {
977 objectName: "buttonSectionMenuControl"
978 text: getExtendedProperty(extendedData, "xCanonicalExtraLabel", "")
981 menuModel.activate(menuIndex);
988 function load(modelData, context) {
989 // tweak indicator-session items
990 if (context === "indicator-session") {
991 if ((modelData.action === "indicator.logout" || modelData.action === "indicator.suspend" || modelData.action === "indicator.hibernate" ||
992 modelData.action === "indicator.reboot")
994 return null; // logout, suspend and hibernate hidden on devices
998 if (modelData.type !== undefined && modelData.type !== "") {
999 var component = undefined;
1001 var contextComponents = _map[context];
1002 if (contextComponents !== undefined) {
1003 component = contextComponents[modelData.type];
1006 if (component === undefined) {
1007 component = _map["default"][modelData.type];
1009 if (component !== undefined) {
1012 console.debug("Don't know how to make " + modelData.type + " for " + context);
1014 if (modelData.isCheck || modelData.isRadio) {
1015 return checkableMenu;
1017 if (modelData.isSeparator) {
1018 return separatorMenu;
1020 return standardMenu;