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 Unity.Indicators 0.1 as Indicators
22import Unity.Indicators.Network 0.1 as ICNetwork
23import Unity.Indicators.Messaging 0.1 as ICMessaging
24import QMenuModel 0.1 as QMenuModel
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" : 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,
43 "com.canonical.indicator.messages.messageitem" : messageItem,
44 "com.canonical.indicator.messages.sourceitem" : groupedMessage,
46 "com.canonical.unity.slider" : sliderMenu,
47 "com.canonical.unity.switch" : switchMenu,
49 "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
50 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
53 function getExtendedProperty(object, propertyName, defaultValue) {
54 if (object && object.hasOwnProperty(propertyName)) {
55 return object[propertyName];
60 Component { id: divMenu; Indicators.DivMenuItem {} }
64 Indicators.SliderMenuItem {
65 property QtObject menuData: null
66 property var menuModel: menuFactory.menuModel
67 property int menuIndex: -1
68 property var extendedData: menuData && menuData.ext || undefined
70 text: menuData && menuData.label || ""
71 iconSource: menuData && menuData.icon || ""
72 minIcon: getExtendedProperty(extendedData, "minIcon", "")
73 maxIcon: getExtendedProperty(extendedData, "maxIcon", "")
75 minimumValue: getExtendedProperty(extendedData, "minValue", 0.0)
77 var maximum = getExtendedProperty(extendedData, "maxValue", 1.0);
78 if (maximum <= minimumValue) {
79 return minimumValue + 1;
83 value: menuData && menuData.actionState || 0.0
84 enabled: menuData && menuData.sensitive || false
93 menuModel.changeState(menuIndex, value);
96 function loadAttributes() {
97 if (!menuModel || menuIndex == undefined) return;
98 menuModel.loadExtendedAttributes(menuIndex, {'min-value': 'double',
99 'max-value': 'double',
101 'max-icon': 'icon'});
108 Indicators.ButtonMenuItem {
109 property QtObject menuData: null
110 property var menuModel: menuFactory.menuModel
111 property int menuIndex: -1
113 text: menuData && menuData.label || ""
114 enabled: menuData && menuData.sensitive || false
117 menuModel.activate(menuIndex);
118 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
124 Indicators.SectionMenuItem {
125 property QtObject menuData: null
126 property var menuIndex: undefined
128 text: menuData && menuData.label || ""
134 Indicators.ProgressMenuItem {
135 property QtObject menuData: null
136 property int menuIndex: -1
138 text: menuData && menuData.label || ""
139 iconSource: menuData && menuData.icon || ""
140 value : menuData && menuData.actionState || 0.0
141 enabled: menuData && menuData.sensitive || false
147 Indicators.StandardMenuItem {
148 property QtObject menuData: null
149 property int menuIndex: -1
151 text: menuData && menuData.label || ""
152 iconSource: menuData && menuData.icon || ""
153 enabled: menuData && menuData.sensitive || false
154 checkable: menuData ? (menuData.isCheck || menuData.isRadio) : false
155 checked: checkable ? menuData.isToggled : false
158 menuModel.activate(menuIndex);
159 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
166 Indicators.SwitchMenuItem {
167 property QtObject menuData: null
168 property int menuIndex: -1
170 text: menuData && menuData.label || ""
171 iconSource: menuData && menuData.icon || ""
172 enabled: menuData && menuData.sensitive || false
173 checked: menuData ? menuData.isToggled : false
176 menuModel.activate(menuIndex);
177 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
184 Indicators.SectionMenuItem {
185 property QtObject menuData: null
186 property var menuModel: menuFactory.menuModel
187 property int menuIndex: -1
188 property var extendedData: menuData && menuData.ext || undefined
190 text: menuData && menuData.label || ""
191 busy: getExtendedProperty(extendedData, "xCanonicalBusyAction", false)
193 onMenuModelChanged: {
196 onMenuIndexChanged: {
200 function loadAttributes() {
201 if (!menuModel || menuIndex == undefined) return;
202 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'})
209 ICNetwork.AccessPoint {
210 property QtObject menuData: null
211 property var menuModel: menuFactory.menuModel
212 property int menuIndex: -1
213 property var extendedData: menuData && menuData.ext || undefined
215 property var strengthAction: QMenuModel.UnityMenuAction {
218 name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
221 text: menuData && menuData.label || ""
222 enabled: menuData && menuData.sensitive || false
223 secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
224 adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
225 checked: menuData ? menuData.isToggled : false
226 signalStrength: strengthAction.valid ? strengthAction.state : 0
228 onMenuModelChanged: {
231 onMenuIndexChanged: {
235 menuModel.activate(menuIndex);
236 shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
239 function loadAttributes() {
240 if (!menuModel || menuIndex == undefined) return;
241 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
242 'x-canonical-wifi-ap-is-secure': 'bool',
243 'x-canonical-wifi-ap-strength-action': 'string'});
250 ICMessaging.MessageMenuItemFactory {
251 menuModel: menuFactory.menuModel
257 ICMessaging.GroupedMessage {
258 property QtObject menuData: null
259 property var menuModel: menuFactory.menuModel
260 property int menuIndex: -1
261 property var extendedData: menuData && menuData.ext || undefined
263 title: menuData && menuData.label || ""
264 appIcon: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_app.svg")
265 count: menuData && menuData.actionState.length > 0 ? menuData.actionState[0] : "0"
266 enabled: menuData && menuData.sensitive || false
268 onMenuModelChanged: {
271 onMenuIndexChanged: {
275 menuModel.activate(menuIndex, true);
276 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
279 menuModel.activate(menuIndex, false);
282 function loadAttributes() {
283 if (!menuModel || menuIndex == undefined) return;
284 menuModel.loadExtendedAttributes(modelIndex, {'icon': 'icon'});
289 function load(modelData) {
290 if (modelData.type !== undefined) {
291 var component = _map[modelData.type];
292 if (component !== undefined) {
296 if (modelData.isSeparator) {
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