Merge lp:~ken-vandine/ubuntu-system-settings/lp1472505 into lp:ubuntu-system-settings

Proposed by Ken VanDine on 2015-07-09
Status: Merged
Approved by: Jonas G. Drange on 2015-07-13
Approved revision: 1466
Merged at revision: 1470
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/lp1472505
Merge into: lp:ubuntu-system-settings
Diff against target: 94 lines (+39/-13)
1 file modified
plugins/wifi/MenuItemFactory.qml (+39/-13)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/lp1472505
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) 2015-07-09 Approve on 2015-07-13
PS Jenkins bot continuous-integration Needs Fixing on 2015-07-09
Review via email: mp+264299@code.launchpad.net

Commit Message

[wifi] Fixed handling of loading extended attributes from the MenuModel

Description of the Change

[wifi] Fixed handling of loading extended attributes from the MenuModel

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/wifi/MenuItemFactory.qml'
2--- plugins/wifi/MenuItemFactory.qml 2015-04-20 15:08:41 +0000
3+++ plugins/wifi/MenuItemFactory.qml 2015-07-09 15:16:36 +0000
4@@ -40,6 +40,13 @@
5 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
6 }
7
8+ function getExtendedProperty(object, propertyName, defaultValue) {
9+ if (object && object.hasOwnProperty(propertyName)) {
10+ return object[propertyName];
11+ }
12+ return defaultValue;
13+ }
14+
15 Component { id: divMenu; DivMenuItem {} }
16
17 Component {
18@@ -95,13 +102,22 @@
19 id: wifiSection;
20 SectionMenuItem {
21 property QtObject menu: null
22+ property var menuModel: menuFactory.menuModel
23 property int menuIndex: -1
24-
25+ property var extendedData: menu && menu.ext || undefined
26 text: menu && menu.label ? menu.label : ""
27- busy: menu ? menu.ext.xCanonicalBusyAction : false
28-
29- Component.onCompleted: {
30- model.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'});
31+ busy: getExtendedProperty(extendedData, "xCanonicalBusyAction", false)
32+
33+ onMenuModelChanged: {
34+ loadAttributes();
35+ }
36+ onMenuIndexChanged: {
37+ loadAttributes();
38+ }
39+
40+ function loadAttributes() {
41+ if (!menuModel || menuIndex == undefined) return;
42+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-busy-action': 'bool'})
43 }
44 }
45 }
46@@ -111,24 +127,27 @@
47 AccessPoint {
48 id: apItem
49 property QtObject menu: null
50+ property var menuModel: menuFactory.model
51 property int menuIndex: -1
52+ property var extendedData: menu && menu.ext || undefined
53 property var strenthAction: QMenuModel.UnityMenuAction {
54- model: menuFactory.model ? menuFactory.model : null
55- name: menu ? menu.ext.xCanonicalWifiApStrengthAction : ""
56+ model: menuModel ? menuModel : null
57+ name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
58 }
59 property bool serverChecked: menu && menu.isToggled || false
60
61 text: menu && menu.label ? menu.label : ""
62- secure: menu ? menu.ext.xCanonicalWifiApIsSecure : false
63- adHoc: menu ? menu.ext.xCanonicalWifiApIsAdhoc : false
64+ secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
65+ adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
66 checked: serverChecked
67 signalStrength: strenthAction.valid ? strenthAction.state : 0
68 enabled: menu ? menu.sensitive : false
69
70- Component.onCompleted: {
71- model.loadExtendedAttributes(menuIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
72- 'x-canonical-wifi-ap-is-secure': 'bool',
73- 'x-canonical-wifi-ap-strength-action': 'string'});
74+ onMenuModelChanged: {
75+ loadAttributes();
76+ }
77+ onMenuIndexChanged: {
78+ loadAttributes();
79 }
80
81 USC.ServerPropertySynchroniser {
82@@ -140,6 +159,13 @@
83
84 onSyncTriggered: model.activate(apItem.menuIndex)
85 }
86+
87+ function loadAttributes() {
88+ if (!model || menuIndex == undefined) return;
89+ model.loadExtendedAttributes(menuIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
90+ 'x-canonical-wifi-ap-is-secure': 'bool',
91+ 'x-canonical-wifi-ap-strength-action': 'string'});
92+ }
93 }
94 }
95

Subscribers

People subscribed via source and target branches