on xenial help sign in
better handling of indicator menu factory object creation.
f5a8ec7Nick Dedekind
plugins/IndicatorsClient/qml/FactoryMenu.qml+58−45
@@ -18,7 +18,9 @@
18 */
18 */
19
19
20import QtQuick 2.0
20import 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
22
24
23Item {
25Item {
24 id: __menuFactory
26 id: __menuFactory
@@ -27,69 +29,80 @@ Item {
27 property QtObject listView
29 property QtObject listView
28 property QtObject actionGroup
30 property QtObject actionGroup
29 property bool isCurrentItem
31 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
31
35
32 signal selectItem(int targetIndex)
36 signal selectItem(int targetIndex)
33
37
34 property var _map: {
38 property var _map: {
35− "unity.widgets.systemsettings.tablet.volumecontrol" : "IndicatorsClient.SliderMenu",
39+ "unity.widgets.systemsettings.tablet.volumecontrol" : sliderMenu,
36− "unity.widgets.systemsettings.tablet.switch" : "IndicatorsClient.SwitchMenu",
40+ "unity.widgets.systemsettings.tablet.switch" : switchMenu,
37− "unity.widgets.systemsettings.tablet.switch" : "IndicatorsClient.DashApps",
38
41
39− "com.canonical.indicator.button" : "IndicatorsClient.ButtonMenu",
42+ "com.canonical.indicator.button" : buttomMenu,
40− "com.canonical.indicator.div" : "IndicatorsClient.DivMenu",
43+ "com.canonical.indicator.div" : divMenu,
41− "com.canonical.indicator.section" : "IndicatorsClient.MenuSection",
44+ "com.canonical.indicator.section" : sectionMenu,
42− "com.canonical.indicator.progress" : "IndicatorsClient.ProgressMenu",
45+ "com.canonical.indicator.progress" : progressMenu,
43− "com.canonical.indicator.slider" : "IndicatorsClient.SliderMenu",
46+ "com.canonical.indicator.slider" : sliderMenu,
44− "com.canonical.indicator.switch" : "IndicatorsClient.SwitchMenu",
47+ "com.canonical.indicator.switch" : switchMenu,
45
48
46− "com.canonical.indicator.messages.messageitem" : "IndicatorsClient.Messaging.MessageItem",
49+ "com.canonical.indicator.messages.messageitem" : messageItem,
47− "com.canonical.indicator.messages.snapdecision" : "IndicatorsClient.Messaging.SnapDecision",
50+ "com.canonical.indicator.messages.snapdecision" : snapDecision,
48− "com.canonical.indicator.messages.sourceitem" : "IndicatorsClient.Messaging.GroupedMessage",
51+ "com.canonical.indicator.messages.sourceitem" : groupedMessage,
49
52
50− "unity.widget.systemsettings.tablet.sectiontitle" : "IndicatorsClient.Network.WifiSection",
53+ "unity.widget.systemsettings.tablet.sectiontitle" : wifiSection,
51− "unity.widgets.systemsettings.tablet.wifisection" : "IndicatorsClient.Network.WifiSection",
54+ "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
52− "unity.widgets.systemsettings.tablet.accesspoint" : "IndicatorsClient.Network.Accesspoint",
55+ "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
53 }
56 }
54
57
55− function get_qml_string(type) {
58+ Component { id: sliderMenu; IC.SliderMenu {} }
56− return "import QtQuick 2.0; import IndicatorsClient 0.1 as IndicatorsClient; " + type + " {}";
59+ Component { id: switchMenu; IC.SwitchMenu {} }
57− }
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 {} }
58
69
59− QtObject {
70+ Component { id: indicatorMenu; IC.Menu {Component.onCompleted: console.log("menu created");} }
60− id: __loader
61
71
62− property var object: {
72+ Loader {
73+ id: __loader
74+ anchors.fill: parent
75+ asynchronous: true
76+ sourceComponent: {
63− if (!__menuFactory.menu || !__menuFactory.menu.extra) {
77+ if (!__menuFactory.menu || !__menuFactory.menu.extra) {
64− return undefined
78+ return undefined
65− }
79+ }
66
80
67− var tmp_object = undefined
68− var widgetType = __menuFactory.menu.extra.canonical_type
81+ var widgetType = __menuFactory.menu.extra.canonical_type
82+ var sourceFile = null
69− if (widgetType) {
83+ if (widgetType) {
70− var component_type = _map[widgetType]
84+ var component = _map[widgetType]
71− if (component_type != undefined) {
85+ if (component != undefined) {
72− tmp_object = Qt.createQmlObject(get_qml_string(component_type), __menuFactory)
86+ console.log(component);
87+ return component
88+ }
73 }
89 }
74− }
75− if (tmp_object == undefined) {
76 if (widgetType === "com.canonical.indicator.root") {
90 if (widgetType === "com.canonical.indicator.root") {
77− tmp_object = undefined
91+ return undefined
78 // Try discovery the item based on the basic properties
92 // Try discovery the item based on the basic properties
79 } else if (menu.hasSection) {
93 } else if (menu.hasSection) {
80− tmp_object = Qt.createQmlObject(get_qml_string("IndicatorsClient.SectionMenu"), __menuFactory)
94+ return sectionMenu
81− } else {
82− tmp_object = Qt.createQmlObject(get_qml_string("IndicatorsClient.Menu"), __menuFactory)
83 }
95 }
96+ return indicatorMenu
84 }
97 }
85− if (tmp_object != undefined) {
98+
99+ onStatusChanged: {
100+ if (status == Loader.Ready) {
86− tmp_object.listViewIsCurrentItem = Qt.binding(function() { return isCurrentItem; });
101+ item.listViewIsCurrentItem = Qt.binding(function() { return isCurrentItem; });
87− tmp_object.actionGroup = Qt.binding(function() { return __menuFactory.actionGroup; });
102+ item.actionGroup = Qt.binding(function() { return __menuFactory.actionGroup; });
88− tmp_object.menu = Qt.binding(function() { return __menuFactory.menu; });
103+ item.menu = Qt.binding(function() { return __menuFactory.menu; });
104+ }
89 }
105 }
90− return tmp_object
91− }
92 }
106 }
93
107
94− implicitHeight: __loader.object ? __loader.object.implicitHeight : 0
95}
108}
plugins/IndicatorsClient/qml/messaging/GroupedMessage.qml+1−3
@@ -22,15 +22,13 @@ import QtQuick 2.0
22import Ubuntu.Components 0.1
22import Ubuntu.Components 0.1
23import IndicatorsClient 0.1 as IndicatorsClient
23import IndicatorsClient 0.1 as IndicatorsClient
24
24
25−IndicatorsClient.RemovableMenu {
25+IndicatorsClient.BasicMenu {
26 property variant action: menu && actionGroup ? actionGroup.action(menu.action) : undefined
26 property variant action: menu && actionGroup ? actionGroup.action(menu.action) : undefined
27 property alias count: label.text
27 property alias count: label.text
28
28
29 color: "#221e1b"
29 color: "#221e1b"
30 implicitHeight: units.gu(10)
30 implicitHeight: units.gu(10)
31
31
32− onSwipingChanged: listView.interactive = !swiping
33−
34 Row {
32 Row {
35 anchors.fill: parent
33 anchors.fill: parent
36 anchors.margins: units.gu(2)
34 anchors.margins: units.gu(2)
plugins/IndicatorsClient/qml/network/Accesspoint.qml → plugins/IndicatorsClient/qml/network/AccessPoint.qmlrenamed

The content is the same.