@@ -18,6 +18,7 @@
1818 */
1919
2020import QtQuick 2.0
21+import IndicatorsClient 0.1 as IndicatorsClient
2122
2223Item {
2324 id: __menuFactory
@@ -25,66 +26,70 @@ Item {
2526 property QtObject menu
2627 property QtObject listView
2728 property QtObject actionGroup
28− property variant widgetsMap
2929 property bool isCurrentItem
30− readonly property bool empty: (__loader.source !== "" && __loader.status == Loader.Ready) ? __loader.item.state === "EMPTY" : true
30+ readonly property bool empty: (__loader.object !== undefined) ? __loader.object.state === "EMPTY" : true
3131
3232 signal selectItem(int targetIndex)
3333
34− implicitHeight: (__loader.status === Loader.Ready) ? __loader.item.implicitHeight : 0
35− Loader {
34+ property var _map: {
35+ "unity.widgets.systemsettings.tablet.volumecontrol" : "IndicatorsClient.SliderMenu",
36+ "unity.widgets.systemsettings.tablet.switch" : "IndicatorsClient.SwitchMenu",
37+ "unity.widgets.systemsettings.tablet.switch" : "IndicatorsClient.DashApps",
38+
39+ "com.canonical.indicator.button" : "IndicatorsClient.ButtonMenu",
40+ "com.canonical.indicator.div" : "IndicatorsClient.DivMenu",
41+ "com.canonical.indicator.section" : "IndicatorsClient.MenuSection",
42+ "com.canonical.indicator.progress" : "IndicatorsClient.ProgressMenu",
43+ "com.canonical.indicator.slider" : "IndicatorsClient.SliderMenu",
44+ "com.canonical.indicator.switch" : "IndicatorsClient.SwitchMenu",
45+
46+ "com.canonical.indicator.messages.messageitem" : "IndicatorsClient.Messaging.MessageItem",
47+ "com.canonical.indicator.messages.snapdecision" : "IndicatorsClient.Messaging.SnapDecision",
48+ "com.canonical.indicator.messages.sourceitem" : "IndicatorsClient.Messaging.GroupedMessage",
49+
50+ "unity.widget.systemsettings.tablet.sectiontitle" : "IndicatorsClient.Network.WifiSection",
51+ "unity.widgets.systemsettings.tablet.wifisection" : "IndicatorsClient.Network.WifiSection",
52+ "unity.widgets.systemsettings.tablet.accesspoint" : "IndicatorsClient.Network.Accesspoint",
53+ }
54+
55+ function get_qml_string(type) {
56+ return "import QtQuick 2.0; import IndicatorsClient 0.1 as IndicatorsClient; " + type + " {}";
57+ }
58+
59+ QtObject {
3660 id: __loader
37− anchors.fill: parent
38− asynchronous: true
39− source: {
40− if (!__menuFactory.menu || !__menuFactory.menu.extra || !__menuFactory.widgetsMap) {
41− return ''
61+
62+ property var object: {
63+ if (!__menuFactory.menu || !__menuFactory.menu.extra) {
64+ return undefined
4265 }
4366
67+ var tmp_object = undefined
4468 var widgetType = __menuFactory.menu.extra.canonical_type
45− var sourceFile = null
4669 if (widgetType) {
47− sourceFile = __menuFactory.widgetsMap.find(widgetType)
70+ var component_type = _map[widgetType]
71+ if (component_type != undefined) {
72+ tmp_object = Qt.createQmlObject(get_qml_string(component_type), __menuFactory)
73+ }
4874 }
49− if (!sourceFile) {
75+ if (tmp_object == undefined) {
5076 if (widgetType === "com.canonical.indicator.root") {
51− sourceFile == ""
77+ tmp_object = undefined
5278 // Try discovery the item based on the basic properties
5379 } else if (menu.hasSection) {
54− sourceFile = "SectionMenu.qml"
80+ tmp_object = Qt.createQmlObject(get_qml_string("IndicatorsClient.SectionMenu"), __menuFactory)
5581 } else {
56− sourceFile = "Menu.qml"
82+ tmp_object = Qt.createQmlObject(get_qml_string("IndicatorsClient.Menu"), __menuFactory)
5783 }
5884 }
59− return sourceFile
60− }
61− onStatusChanged: {
62− if (status == Loader.Ready) {
63− item.listViewIsCurrentItem = __menuFactory.isCurrentItem
85+ if (tmp_object != undefined) {
86+ tmp_object.listViewIsCurrentItem = Qt.binding(function() { return isCurrentItem; });
87+ tmp_object.actionGroup = Qt.binding(function() { return __menuFactory.actionGroup; });
88+ tmp_object.menu = Qt.binding(function() { return __menuFactory.menu; });
6489 }
65− }
66−
67− // Binding all properties for the item, to make sure that any change in the
68− // property will be propagated to the __loader.item at any time
69− Binding {
70− target: __loader.item
71− property: "listViewIsCurrentItem"
72− value: isCurrentItem
73− when: (__loader.status == Loader.Ready)
74− }
75−
76− Binding {
77− target: __loader.item
78− property: "actionGroup"
79− value: __menuFactory.actionGroup
80− when: (__loader.status == Loader.Ready)
81− }
82−
83− Binding {
84− target: __loader.item
85− property: "menu"
86− value: __menuFactory.menu
87− when: (__loader.status == Loader.Ready)
90+ return tmp_object
8891 }
8992 }
93+
94+ implicitHeight: __loader.object ? __loader.object.implicitHeight : 0
9095}