on dde0fa0 help sign in
unity8/plugins/Unity/Indicators/qml/MenuItemFactory.qml
95 lines 3.5 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
20import QtQuick 2.0
21import Unity.Indicators 0.1 as Indicators
22import Unity.Indicators.Network 0.1 as ICNetwork
24Item {
25 id: menuFactory
27 property var model: null
29 property var _map: {
30 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
31 "unity.widgets.systemsettings.tablet.switch" : switchMenu,
33 "com.canonical.indicator.button" : buttonMenu,
34 "com.canonical.indicator.div" : divMenu,
35 "com.canonical.indicator.section" : sectionMenu,
36 "com.canonical.indicator.progress" : progressMenu,
37 "com.canonical.indicator.slider" : sliderMenu,
38 "com.canonical.indicator.switch" : switchMenu,
40 "com.canonical.unity.slider" : sliderMenu,
41 "com.canonical.unity.switch" : switchMenu,
43 "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
44 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
45 }
47 Component {
48 id: sliderMenu;
49 Indicators.SliderMenuItem {
50 Component.onCompleted: {
51 model.loadExtendedAttributes(modelIndex, {'min-value': 'double',
52 'max-value': 'double',
53 'min-icon': 'icon',
54 'max-icon': 'icon'});
55 }
56 }
57 }
58 Component { id: buttonMenu; Indicators.ButtonMenuItem {} }
59 Component { id: divMenu; Indicators.DivMenuItem {} }
60 Component { id: sectionMenu; Indicators.SectionMenuItem {} }
61 Component { id: progressMenu; Indicators.ProgressMenuItem {} }
62 Component { id: standardMenu; Indicators.StandardMenuItem {} }
63 Component { id: switchMenu; Indicators.SwitchMenuItem {} }
64 Component {
65 id: wifiSection;
66 ICNetwork.WifiSection {
67 Component.onCompleted: {
68 model.loadExtendedAttributes(modelIndex, {'x-canonical-busy-action': 'bool'});
69 }
70 }
71 }
72 Component {
73 id: accessPoint;
74 ICNetwork.AccessPoint {
75 Component.onCompleted: {
76 model.loadExtendedAttributes(modelIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
77 'x-canonical-wifi-ap-is-secure': 'bool'});
78 }
79 }
80 }
82 function load(modelData) {
83 if (modelData.type !== undefined) {
84 var component = _map[modelData.type];
85 if (component !== undefined) {
86 return component;
87 }
88 } else {
89 if (modelData.isSeparator) {
90 return divMenu;
91 }
92 }
93 return standardMenu;
94 }