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
29 property var menuModel: null
32 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
33 "unity.widgets.systemsettings.tablet.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,
44 "com.canonical.indicator.messages.messageitem" : messageItem,
45 "com.canonical.indicator.messages.sourceitem" : groupedMessage,
47 "com.canonical.unity.slider" : sliderMenu,
48 "com.canonical.unity.switch" : switchMenu,
50 "com.canonical.unity.media-player" : mediaPayerMenu,
51 "com.canonical.unity.playback-item" : playbackItemMenu,
53 "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
54 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
57 function getExtendedProperty(object, propertyName, defaultValue) {
58 if (object && object.hasOwnProperty(propertyName)) {
59 return object[propertyName];
67 objectName: "separatorMenu"
74 objectName: "sliderMenu"
75 property QtObject menuData: null
76 property var menuModel: menuFactory.menuModel
77 property int menuIndex: -1
78 property var extendedData: menuData && menuData.ext || undefined
80 text: menuData && menuData.label || ""
81 iconSource: menuData && menuData.icon || ""
82 minIcon: getExtendedProperty(extendedData, "minIcon", "")
83 maxIcon: getExtendedProperty(extendedData, "maxIcon", "")
85 minimumValue: getExtendedProperty(extendedData, "minValue", 0.0)
87 var maximum = getExtendedProperty(extendedData, "maxValue", 1.0);
88 if (maximum <= minimumValue) {
89 return minimumValue + 1;
93 value: menuData && menuData.actionState || 0.0
94 enabled: menuData && menuData.sensitive || false
103 menuModel.changeState(menuIndex, value);
106 function loadAttributes() {
107 if (!menuModel || menuIndex == -1) return;
108 menuModel.loadExtendedAttributes(menuIndex, {'min-value': 'double',
109 'max-value': 'double',
111 'max-icon': 'icon'});
119 objectName: "buttonMenu"
120 property QtObject menuData: null
121 property var menuModel: menuFactory.menuModel
122 property int menuIndex: -1
124 buttonText: menuData && menuData.label || ""
125 enabled: menuData && menuData.sensitive || false
128 menuModel.activate(menuIndex);
129 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
136 objectName: "sectionMenu"
137 property QtObject menuData: null
138 property var menuIndex: undefined
140 text: menuData && menuData.label || ""
147 Menus.ProgressValueMenu {
148 objectName: "progressMenu"
149 property QtObject menuData: null
150 property int menuIndex: -1
152 text: menuData && menuData.label || ""
153 iconSource: menuData && menuData.icon || ""
154 value : menuData && menuData.actionState || 0.0
155 enabled: menuData && menuData.sensitive || false
162 objectName: "standardMenu"
163 property QtObject menuData: null
164 property int menuIndex: -1
166 text: menuData && menuData.label || ""
167 iconSource: menuData && menuData.icon || ""
168 enabled: menuData && menuData.sensitive || false
171 menuModel.activate(menuIndex);
172 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
179 Menus.CheckableMenu {
180 objectName: "checkableMenu"
181 property QtObject menuData: null
182 property int menuIndex: -1
184 text: menuData && menuData.label || ""
185 enabled: menuData && menuData.sensitive || false
186 checked: menuData && menuData.isToggled || false
189 menuModel.activate(menuIndex);
190 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
199 objectName: "switchMenu"
200 property QtObject menuData: null
201 property int menuIndex: -1
203 text: menuData && menuData.label || ""
204 iconSource: menuData && menuData.icon || ""
205 enabled: menuData && menuData.sensitive || false
206 checked: menuData && menuData.isToggled || false
209 menuModel.activate(menuIndex);
210 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
218 objectName: "alarmMenu"
219 property QtObject menuData: null
220 property var menuModel: menuFactory.menuModel
221 property int menuIndex: -1
222 property var extendedData: menuData && menuData.ext || undefined
223 // TODO - bug #1260728
224 property var timeFormatter: Utils.GDateTimeFormatter {
225 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
226 format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
229 text: menuData && menuData.label || ""
230 iconSource: menuData && menuData.icon || "image://theme/alarm-clock"
231 time: timeFormatter.timeString
232 enabled: menuData && menuData.sensitive || false
234 onMenuModelChanged: {
237 onMenuIndexChanged: {
241 menuModel.activate(menuIndex);
244 function loadAttributes() {
245 if (!menuModel || menuIndex == -1) return;
246 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-time': 'int64',
247 'x-canonical-time-format': 'string'});
255 objectName: "appointmentMenu"
256 property QtObject menuData: null
257 property var menuModel: menuFactory.menuModel
258 property int menuIndex: -1
259 property var extendedData: menuData && menuData.ext || undefined
260 // TODO - bug #1260728
261 property var timeFormatter: Utils.GDateTimeFormatter {
262 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
263 format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
266 text: menuData && menuData.label || ""
267 iconSource: menuData && menuData.icon || "image://theme/calendar"
268 time: timeFormatter.timeString
269 eventColor: menu && menu.ext.hasOwnProperty("xCanonicalColor") ? menu.ext.xCanonicalColor : Qt.rgba(0.0, 0.0, 0.0, 0.0)
270 enabled: menuData && menuData.sensitive || false
272 onMenuModelChanged: {
275 onMenuIndexChanged: {
279 menuModel.activate(menuIndex);
282 function loadAttributes() {
283 if (!menuModel || menuIndex == -1) return;
284 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-color': 'string',
285 'x-canonical-time': 'int64',
286 'x-canonical-time-format': 'string'});
294 objectName: "wifiSection"
295 property QtObject menuData: null
296 property var menuModel: menuFactory.menuModel
297 property int menuIndex: -1
298 property var extendedData: menuData && menuData.ext || undefined
300 text: menuData && menuData.label || ""
301 busy: getExtendedProperty(extendedData, "xCanonicalBusyAction", false)
303 onMenuModelChanged: {
306 onMenuIndexChanged: {
310 function loadAttributes() {
311 if (!menuModel || menuIndex == -1) return;
312 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'})
319 Menus.AccessPointMenu {
320 objectName: "accessPoint"
321 property QtObject menuData: null
322 property var menuModel: menuFactory.menuModel
323 property int menuIndex: -1
324 property var extendedData: menuData && menuData.ext || undefined
326 property var strengthAction: QMenuModel.UnityMenuAction {
329 name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
332 text: menuData && menuData.label || ""
333 enabled: menuData && menuData.sensitive || false
334 checked: menuData && menuData.isToggled || false
335 secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
336 adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
337 signalStrength: strengthAction.valid ? strengthAction.state : 0
339 onMenuModelChanged: {
342 onMenuIndexChanged: {
346 menuModel.activate(menuIndex);
347 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
350 function loadAttributes() {
351 if (!menuModel || menuIndex == -1) return;
352 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
353 'x-canonical-wifi-ap-is-secure': 'bool',
354 'x-canonical-wifi-ap-strength-action': 'string'});
361 MessageMenuItemFactory {
362 objectName: "messageItem"
363 menuModel: menuFactory.menuModel
369 Menus.GroupedMessageMenu {
370 objectName: "groupedMessage"
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 text: menuData && menuData.label || ""
377 iconSource: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_app.svg")
378 count: menuData && menuData.actionState.length > 0 ? menuData.actionState[0] : "0"
379 enabled: menuData && menuData.sensitive || false
382 onMenuModelChanged: {
385 onMenuIndexChanged: {
389 menuModel.activate(menuIndex, true);
390 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
393 menuModel.activate(menuIndex, false);
396 function loadAttributes() {
397 if (!menuModel || menuIndex == -1) return;
398 menuModel.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
405 Menus.MediaPlayerMenu {
406 objectName: "mediaPayerMenu"
407 property QtObject menuData: null
408 property var menuModel: menuFactory.menuModel
409 property int menuIndex: -1
410 property var actionState: menuData && menuData.actionState || undefined
412 playerIcon: menuData && menuData.icon || ""
413 playerName: menuData && menuData.label || ""
415 albumArt: getExtendedProperty(actionState, "art-url", "")
416 song: getExtendedProperty(actionState, "title", "unknown")
417 artist: getExtendedProperty(actionState, "artist", "unknown")
418 album: getExtendedProperty(actionState, "album", "unknown")
419 running: getExtendedProperty(actionState, "running", false)
420 state: getExtendedProperty(actionState, "state", "")
421 enabled: menuData && menuData.sensitive || false
424 model.activate(modelIndex);
430 id: playbackItemMenu;
431 Menus.PlaybackItemMenu {
432 objectName: "playbackItemMenu"
433 property QtObject menuData: null
434 property var menuModel: menuFactory.menuModel
435 property int menuIndex: -1
436 property var extendedData: menuData && menuData.ext || undefined
438 property var playAction: QMenuModel.UnityMenuAction {
441 name: getExtendedProperty(extendedData, "xCanonicalPlayAction", "")
443 property var nextAction: QMenuModel.UnityMenuAction {
446 name: getExtendedProperty(extendedData, "xCanonicalNextAction", "")
448 property var previousAction: QMenuModel.UnityMenuAction {
451 name: getExtendedProperty(extendedData, "xCanonicalPreviousAction", "")
454 playing: playAction.state === "Playing"
455 canPlay: playAction.valid
456 canGoNext: nextAction.valid
457 canGoPrevious: previousAction.valid
458 enabled: menuData && menuData.sensitive || false
461 playAction.activate();
464 nextAction.activate();
467 previousAction.activate();
469 onMenuModelChanged: {
472 onMenuIndexChanged: {
476 function loadAttributes() {
477 if (!menuModel || menuIndex == -1) return;
478 menuModel.loadExtendedAttributes(modelIndex, {'x-canonical-play-action': 'string',
479 'x-canonical-next-action': 'string',
480 'x-canonical-previous-action': 'string'});
485 function load(modelData) {
486 if (modelData.type !== undefined) {
487 var component = _map[modelData.type];
488 if (component !== undefined) {
492 if (modelData.isCheck || modelData.isRadio) {
493 return checkableMenu;
495 if (modelData.isSeparator) {
496 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