on xenial help sign in
Fixed property bindings to menuData
5607719Nick Dedekind
plugins/Unity/Indicators/Messaging/qml/MessageMenuItemFactory.qml+25−25
@@ -29,8 +29,8 @@ Indicators.BaseMenuItem {
29 property QtObject menuData: null
29 property QtObject menuData: null
30 property var menuIndex: undefined
30 property var menuIndex: undefined
31
31
32− property var extendedData: getProperty(menuData, "ext", undefined)
32+ property var extendedData: menuData && menuData.ext || undefined
33− property var actionsDescription: getProperty(extendedData, "xCanonicalMessageActions", undefined)
33+ property var actionsDescription: getExtendedProperty(extendedData, "xCanonicalMessageActions", undefined)
34
34
35 onMenuModelChanged: {
35 onMenuModelChanged: {
36 loadAttributes();
36 loadAttributes();
@@ -49,7 +49,7 @@ Indicators.BaseMenuItem {
49 'x-canonical-app-icon': 'icon'});
49 'x-canonical-app-icon': 'icon'});
50 }
50 }
51
51
52− function getProperty(object, propertyName, defaultValue) {
52+ function getExtendedProperty(object, propertyName, defaultValue) {
53 if (object && object.hasOwnProperty(propertyName)) {
53 if (object && object.hasOwnProperty(propertyName)) {
54 return object[propertyName];
54 return object[propertyName];
55 }
55 }
@@ -68,12 +68,12 @@ Indicators.BaseMenuItem {
68 id: simpleTextMessage
68 id: simpleTextMessage
69 SimpleTextMessage {
69 SimpleTextMessage {
70 // text
70 // text
71− title: getProperty(menuData, "label", "")
71+ title: menuData && menuData.label || ""
72− time: getProperty(extendedData, "xCanonicalTime", 0)
72+ time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
73− message: getProperty(extendedData, "xCanonicalText", "")
73+ message: getExtendedProperty(extendedData, "xCanonicalText", "")
74 // icons
74 // icons
75− avatar: getProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
75+ avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
76− appIcon: getProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
76+ appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
77
77
78 onActivateApp: {
78 onActivateApp: {
79 menuModel.activate(menuIndex, true);
79 menuModel.activate(menuIndex, true);
@@ -96,17 +96,17 @@ Indicators.BaseMenuItem {
96 property var replyAction: QMenuModel.UnityMenuAction {
96 property var replyAction: QMenuModel.UnityMenuAction {
97 model: menuModel
97 model: menuModel
98 index: menuIndex
98 index: menuIndex
99− name: getProperty(replyActionDescription, "name", "")
99+ name: getExtendedProperty(replyActionDescription, "name", "")
100 }
100 }
101
101
102 // text
102 // text
103− title: getProperty(menuData, "label", "")
103+ title: menuData && menuData.label || ""
104− time: getProperty(extendedData, "xCanonicalTime", 0)
104+ time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
105− message: getProperty(extendedData, "xCanonicalText", "")
105+ message: getExtendedProperty(extendedData, "xCanonicalText", "")
106− replyButtonText: getProperty(replyActionDescription, "label", "Send")
106+ replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
107 // icons
107 // icons
108− avatar: getProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
108+ avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
109− appIcon: getProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
109+ appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
110 // actions
110 // actions
111 replyEnabled: replyAction.valid && replyAction.enabled
111 replyEnabled: replyAction.valid && replyAction.enabled
112
112
@@ -135,24 +135,24 @@ Indicators.BaseMenuItem {
135 property var activateAction: QMenuModel.UnityMenuAction {
135 property var activateAction: QMenuModel.UnityMenuAction {
136 model: menuModel
136 model: menuModel
137 index: menuIndex
137 index: menuIndex
138− name: getProperty(activateActionDescription, "name", "")
138+ name: getExtendedProperty(activateActionDescription, "name", "")
139 }
139 }
140 property var replyAction: QMenuModel.UnityMenuAction {
140 property var replyAction: QMenuModel.UnityMenuAction {
141 model: menuModel
141 model: menuModel
142 index: menuIndex
142 index: menuIndex
143− name: getProperty(replyActionDescription, "name", "")
143+ name: getExtendedProperty(replyActionDescription, "name", "")
144 }
144 }
145
145
146 // text
146 // text
147− title: getProperty(menuData, "label", "")
147+ title: menuData && menuData.label || ""
148− time: getProperty(extendedData, "xCanonicalTime", 0)
148+ time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
149− message: getProperty(extendedData, "xCanonicalText", "")
149+ message: getExtendedProperty(extendedData, "xCanonicalText", "")
150− actionButtonText: getProperty(activateActionDescription, "label", "Call back")
150+ actionButtonText: getExtendedProperty(activateActionDescription, "label", "Call back")
151− replyButtonText: getProperty(replyActionDescription, "label", "Send")
151+ replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
152− replyMessages: getProperty(replyActionDescription, "parameter-hint", "")
152+ replyMessages: getExtendedProperty(replyActionDescription, "parameter-hint", "")
153 // icons
153 // icons
154− avatar: getProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
154+ avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
155− appIcon: getProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
155+ appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
156 // actions
156 // actions
157 activateEnabled: activateAction.valid && activateAction.enabled
157 activateEnabled: activateAction.valid && activateAction.enabled
158 replyEnabled: replyAction.valid && replyAction.enabled
158 replyEnabled: replyAction.valid && replyAction.enabled
plugins/Unity/Indicators/qml/MenuItemFactory.qml+35−35
@@ -50,7 +50,7 @@ Item {
50 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
50 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
51 }
51 }
52
52
53− function getProperty(object, propertyName, defaultValue) {
53+ function getExtendedProperty(object, propertyName, defaultValue) {
54 if (object && object.hasOwnProperty(propertyName)) {
54 if (object && object.hasOwnProperty(propertyName)) {
55 return object[propertyName];
55 return object[propertyName];
56 }
56 }
@@ -65,23 +65,23 @@ Item {
65 property QtObject menuData: null
65 property QtObject menuData: null
66 property var menuModel: menuFactory.menuModel
66 property var menuModel: menuFactory.menuModel
67 property var menuIndex: undefined
67 property var menuIndex: undefined
68− property var extendedData: getProperty(menuData, "ext", undefined)
68+ property var extendedData: menuData && menuData.ext || undefined
69
69
70− text: getProperty(menuData, "label", "")
70+ text: menuData && menuData.label || ""
71− icon: getProperty(menuData, "icon", "")
71+ iconSource: menuData && menuData.icon || ""
72− minIcon: getProperty(extendedData, "minIcon", "")
72+ minIcon: getExtendedProperty(extendedData, "minIcon", "")
73− maxIcon: getProperty(extendedData, "minIcon", "")
73+ maxIcon: getExtendedProperty(extendedData, "minIcon", "")
74
74
75− minimumValue: getProperty(extendedData, "minValue", 0.0)
75+ minimumValue: getExtendedProperty(extendedData, "minValue", 0.0)
76 maximumValue: {
76 maximumValue: {
77− var maximum = getProperty(extendedData, "maxValue", 1.0);
77+ var maximum = getExtendedProperty(extendedData, "maxValue", 1.0);
78 if (maximum <= minimumValue) {
78 if (maximum <= minimumValue) {
79 return minimumValue + 1;
79 return minimumValue + 1;
80 }
80 }
81 return maximum;
81 return maximum;
82 }
82 }
83− value: getProperty(menuData, "actionState", 0.0)
83+ value: menuData && menuData.actionState || 0.0
84− enabled: getProperty(menuData, "sensitive", false)
84+ enabled: menuData && menuData.sensitive || false
85
85
86 onMenuModelChanged: {
86 onMenuModelChanged: {
87 loadAttributes();
87 loadAttributes();
@@ -110,8 +110,8 @@ Item {
110 property var menuModel: menuFactory.menuModel
110 property var menuModel: menuFactory.menuModel
111 property var menuIndex: undefined
111 property var menuIndex: undefined
112
112
113− text: getProperty(menuData, "label", "")
113+ text: menuData && menuData.label || ""
114− enabled: getProperty(menuData, "sensitive", false)
114+ enabled: menuData && menuData.sensitive || false
115
115
116 onActivate: {
116 onActivate: {
117 menuModel.activate(menuIndex);
117 menuModel.activate(menuIndex);
@@ -125,7 +125,7 @@ Item {
125 property QtObject menuData: null
125 property QtObject menuData: null
126 property var menuIndex: undefined
126 property var menuIndex: undefined
127
127
128− text: getProperty(menuData, "label", "")
128+ text: menuData && menuData.label || ""
129 }
129 }
130 }
130 }
131
131
@@ -135,10 +135,10 @@ Item {
135 property QtObject menuData: null
135 property QtObject menuData: null
136 property var menuIndex: undefined
136 property var menuIndex: undefined
137
137
138− text: getProperty(menuData, "label", "")
138+ text: menuData && menuData.label || ""
139− icon: getProperty(menuData, "icon", "")
139+ iconSource: menuData && menuData.icon || ""
140− value : getProperty(menuData, "actionState", 0.0)
140+ value : menuData && menuData.actionState || 0.0
141− enabled: getProperty(menuData, "sensitive", false)
141+ enabled: menuData && menuData.sensitive || false
142 }
142 }
143 }
143 }
144
144
@@ -148,9 +148,9 @@ Item {
148 property QtObject menuData: null
148 property QtObject menuData: null
149 property var menuIndex: undefined
149 property var menuIndex: undefined
150
150
151− text: getProperty(menuData, "label", "")
151+ text: menuData && menuData.label || ""
152− icon: getProperty(menuData, "icon", "")
152+ iconSource: menuData && menuData.icon || ""
153− enabled: getProperty(menuData, "sensitive", false)
153+ enabled: menuData && menuData.sensitive || false
154 checkable: menuData ? (menuData.isCheck || menuData.isRadio) : false
154 checkable: menuData ? (menuData.isCheck || menuData.isRadio) : false
155 checked: checkable ? menuData.isToggled : false
155 checked: checkable ? menuData.isToggled : false
156
156
@@ -167,9 +167,9 @@ Item {
167 property QtObject menuData: null
167 property QtObject menuData: null
168 property var menuIndex: undefined
168 property var menuIndex: undefined
169
169
170− text: getProperty(menuData, "label", "")
170+ text: menuData && menuData.label || ""
171− icon: getProperty(menuData, "icon", "")
171+ iconSource: menuData && menuData.icon || ""
172− enabled: getProperty(menuData, "sensitive", false)
172+ enabled: menuData && menuData.sensitive || false
173 checked: menuData ? menuData.isToggled : false
173 checked: menuData ? menuData.isToggled : false
174
174
175 onActivate: {
175 onActivate: {
@@ -185,10 +185,10 @@ Item {
185 property QtObject menuData: null
185 property QtObject menuData: null
186 property var menuModel: menuFactory.menuModel
186 property var menuModel: menuFactory.menuModel
187 property var menuIndex: undefined
187 property var menuIndex: undefined
188− property var extendedData: getProperty(menuData, "ext", undefined)
188+ property var extendedData: menuData && menuData.ext || undefined
189
189
190− text: getProperty(menuData, "label", "")
190+ text: menuData && menuData.label || ""
191− busy: getProperty(extendedData, "xCanonicalBusyAction", false)
191+ busy: getExtendedProperty(extendedData, "xCanonicalBusyAction", false)
192
192
193 onMenuModelChanged: {
193 onMenuModelChanged: {
194 loadAttributes();
194 loadAttributes();
@@ -210,18 +210,18 @@ Item {
210 property QtObject menuData: null
210 property QtObject menuData: null
211 property var menuModel: menuFactory.menuModel
211 property var menuModel: menuFactory.menuModel
212 property var menuIndex: undefined
212 property var menuIndex: undefined
213− property var extendedData: getProperty(menuData, "ext", undefined)
213+ property var extendedData: menuData && menuData.ext || undefined
214
214
215 property var strengthAction: QMenuModel.UnityMenuAction {
215 property var strengthAction: QMenuModel.UnityMenuAction {
216 model: menuModel
216 model: menuModel
217 index: menuIndex
217 index: menuIndex
218− name: getProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
218+ name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
219 }
219 }
220
220
221− text: getProperty(menuData, "label", "")
221+ text: menuData && menuData.label || ""
222− enabled: getProperty(menuData, "sensitive", false)
222+ enabled: menuData && menuData.sensitive || false
223− secure: getProperty(extendedData, "xCanonicalWifiApIsSecure", false)
223+ secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
224− adHoc: getProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
224+ adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
225 checked: menuData ? menuData.isToggled : false
225 checked: menuData ? menuData.isToggled : false
226 signalStrength: strengthAction.valid ? strengthAction.state : 0
226 signalStrength: strengthAction.valid ? strengthAction.state : 0
227
227
@@ -258,10 +258,10 @@ Item {
258 property QtObject menuData: null
258 property QtObject menuData: null
259 property var menuModel: menuFactory.menuModel
259 property var menuModel: menuFactory.menuModel
260 property var menuIndex: undefined
260 property var menuIndex: undefined
261− property var extendedData: getProperty(menuData, "ext", undefined)
261+ property var extendedData: menuData && menuData.ext || undefined
262
262
263− title: getProperty(menuData, "label", "")
263+ title: menuData && menuData.label || ""
264− appIcon: getProperty(extendedData, "icon", "") && extendedData.hasOwnProperty("qrc:/indicators/artwork/messaging/default_app.svg")
264+ appIcon: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_app.svg")
265 count: menuData && menuData.actionState.length > 0 ? menuData.actionState[0] : "0"
265 count: menuData && menuData.actionState.length > 0 ? menuData.actionState[0] : "0"
266
266
267 onMenuModelChanged: {
267 onMenuModelChanged: {