@@ -18,7 +18,9 @@
1818 */
1919
2020import QtQuick 2.0
21−import IndicatorsClient 0.1 as IndicatorsClient
21+import IndicatorsClient 0.1 as IC
22+import IndicatorsClient.Messaging 0.1 as ICMessaging
23+import IndicatorsClient.Network 0.1 as ICNetwork
2224
2325Item {
2426 id: __menuFactory
@@ -27,69 +29,80 @@ Item {
2729 property QtObject listView
2830 property QtObject actionGroup
2931 property bool isCurrentItem
30− readonly property bool empty: (__loader.object !== undefined) ? __loader.object.state === "EMPTY" : true
32+ readonly property bool empty: (__loader.item !== undefined && __loader.status == Loader.Ready) ? __loader.item.state === "EMPTY" : true
33+
34+ implicitHeight: (__loader.status === Loader.Ready) ? __loader.item.implicitHeight : 0
3135
3236 signal selectItem(int targetIndex)
3337
3438 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",
39+ "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
40+ "unity.widgets.systemsettings.tablet.switch" : switchMenu,
3841
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",
42+ "com.canonical.indicator.button" : buttomMenu,
43+ "com.canonical.indicator.div" : divMenu,
44+ "com.canonical.indicator.section" : sectionMenu,
45+ "com.canonical.indicator.progress" : progressMenu,
46+ "com.canonical.indicator.slider" : sliderMenu,
47+ "com.canonical.indicator.switch" : switchMenu,
4548
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+ "com.canonical.indicator.messages.messageitem" : messageItem,
50+ "com.canonical.indicator.messages.snapdecision" : snapDecision,
51+ "com.canonical.indicator.messages.sourceitem" : groupedMessage,
4952
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+ "unity.widget.systemsettings.tablet.sectiontitle" : wifiSection,
54+ "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
55+ "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
5356 }
5457
55− function get_qml_string(type) {
56− return "import QtQuick 2.0; import IndicatorsClient 0.1 as IndicatorsClient; " + type + " {}";
57− }
58+ Component { id: sliderMenu; IC.SliderMenu {} }
59+ Component { id: switchMenu; IC.SwitchMenu {} }
60+ Component { id: buttomMenu; IC.ButtonMenu {} }
61+ Component { id: divMenu; IC.DivMenu {} }
62+ Component { id: sectionMenu; IC.SectionMenu {} }
63+ Component { id: progressMenu; IC.ProgressMenu {} }
64+ Component { id: messageItem; ICMessaging.MessageItem {} }
65+ Component { id: snapDecision; ICMessaging.SnapDecision {} }
66+ Component { id: groupedMessage; ICMessaging.GroupedMessage {} }
67+ Component { id: wifiSection; ICNetwork.WifiSection {} }
68+ Component { id: accessPoint; ICNetwork.AccessPoint {} }
5869
59− QtObject {
60− id: __loader
70+ Component { id: indicatorMenu; IC.Menu {Component.onCompleted: console.log("menu created");} }
6171
62− property var object: {
63− if (!__menuFactory.menu || !__menuFactory.menu.extra) {
64− return undefined
65− }
72+ Loader {
73+ id: __loader
74+ anchors.fill: parent
75+ asynchronous: true
76+ sourceComponent: {
77+ if (!__menuFactory.menu || !__menuFactory.menu.extra) {
78+ return undefined
79+ }
6680
67− var tmp_object = undefined
68− var widgetType = __menuFactory.menu.extra.canonical_type
69− if (widgetType) {
70− var component_type = _map[widgetType]
71− if (component_type != undefined) {
72− tmp_object = Qt.createQmlObject(get_qml_string(component_type), __menuFactory)
81+ var widgetType = __menuFactory.menu.extra.canonical_type
82+ var sourceFile = null
83+ if (widgetType) {
84+ var component = _map[widgetType]
85+ if (component != undefined) {
86+ console.log(component);
87+ return component
88+ }
7389 }
74− }
75− if (tmp_object == undefined) {
7690 if (widgetType === "com.canonical.indicator.root") {
77− tmp_object = undefined
91+ return undefined
7892 // Try discovery the item based on the basic properties
7993 } else if (menu.hasSection) {
80− tmp_object = Qt.createQmlObject(get_qml_string("IndicatorsClient.SectionMenu"), __menuFactory)
81− } else {
82− tmp_object = Qt.createQmlObject(get_qml_string("IndicatorsClient.Menu"), __menuFactory)
94+ return sectionMenu
8395 }
96+ return indicatorMenu
8497 }
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; });
98+
99+ onStatusChanged: {
100+ if (status == Loader.Ready) {
101+ item.listViewIsCurrentItem = Qt.binding(function() { return isCurrentItem; });
102+ item.actionGroup = Qt.binding(function() { return __menuFactory.actionGroup; });
103+ item.menu = Qt.binding(function() { return __menuFactory.menu; });
104+ }
89105 }
90− return tmp_object
91− }
92106 }
93107
94− implicitHeight: __loader.object ? __loader.object.implicitHeight : 0
95108}