on c2da3ac help sign in
unity8/plugins/Unity/Indicators/qml/MenuItemFactory.qml
74 lines 2.7 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
23Item {
24 id: menuFactory
26 property var model: null
28 property var _map: {
29 "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
30 "unity.widgets.systemsettings.tablet.switch" : switchMenu,
32 "com.canonical.indicator.button" : buttonMenu,
33 "com.canonical.indicator.div" : divMenu,
34 "com.canonical.indicator.section" : sectionMenu,
35 "com.canonical.indicator.progress" : progressMenu,
36 "com.canonical.indicator.slider" : sliderMenu,
37 "com.canonical.indicator.switch" : switchMenu,
39 "com.canonical.unity.slider" : sliderMenu,
40 "com.canonical.unity.switch" : switchMenu,
41 }
43 Component {
44 id: sliderMenu;
45 Indicators.SliderMenuItem {
46 Component.onCompleted: {
47 model.loadExtendedAttributes(modelIndex, {'min-value': 'double',
48 'max-value': 'double',
49 'min-icon': 'icon',
50 'max-icon': 'icon'});
51 }
52 }
53 }
54 Component { id: buttonMenu; Indicators.ButtonMenuItem {} }
55 Component { id: divMenu; Indicators.DivMenuItem {} }
56 Component { id: sectionMenu; Indicators.SectionMenuItem {} }
57 Component { id: progressMenu; Indicators.ProgressMenuItem {} }
58 Component { id: standardMenu; Indicators.StandardMenuItem {} }
59 Component { id: switchMenu; Indicators.SwitchMenuItem {} }
61 function load(modelData) {
62 if (modelData.type !== undefined) {
63 var component = _map[modelData.type];
64 if (component !== undefined) {
65 return component;
66 }
67 } else {
68 if (modelData.isSeparator) {
69 return divMenu;
70 }
71 }
72 return standardMenu;
73 }