on xenial help sign in
refactor Wifi page, WIP
747f44aLukáš Tinkl
qml/Wizard/Pages/30-wifi.qml+59−27
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -14,11 +14,10 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−import QtQuick 2.0
17+import QtQuick 2.3
18import QMenuModel 0.1 as QMenuModel
18import QMenuModel 0.1 as QMenuModel
19import QtSystemInfo 5.0
19import QtSystemInfo 5.0
20import Ubuntu.Components 1.2
20import Ubuntu.Components 1.2
21−import Ubuntu.Components.ListItems 0.1 as ListItem
22import Ubuntu.Settings.Menus 0.1 as Menus
21import Ubuntu.Settings.Menus 0.1 as Menus
23import ".." as LocalComponents
22import ".." as LocalComponents
24
23
@@ -38,6 +37,29 @@ LocalComponents.Page {
38 return defaultValue;
37 return defaultValue;
39 }
38 }
40
39
40+ function getAPIcon(adHoc, signalStrength, secure) {
41+ var imageName = "nm-no-connection";
42+
43+ if (adHoc) {
44+ imageName = "nm-adhoc";
45+ } else if (signalStrength == 0) {
46+ imageName = "nm-signal-00";
47+ } else if (signalStrength <= 25) {
48+ imageName = "nm-signal-25";
49+ } else if (signalStrength <= 50) {
50+ imageName = "nm-signal-50";
51+ } else if (signalStrength <= 75) {
52+ imageName = "nm-signal-75";
53+ } else if (signalStrength <= 100) {
54+ imageName = "nm-signal-100";
55+ }
56+
57+ if (secure) {
58+ imageName += "-secure";
59+ }
60+ return "image://theme/" + imageName;
61+ }
62+
41 QMenuModel.UnityMenuModel {
63 QMenuModel.UnityMenuModel {
42 id: menuModel
64 id: menuModel
43 busName: "com.canonical.indicator.network"
65 busName: "com.canonical.indicator.network"
@@ -71,9 +93,11 @@ LocalComponents.Page {
71
93
72 Component {
94 Component {
73 id: accessPointComponent
95 id: accessPointComponent
74− ListItem.Standard {
96+ ListItem {
75 id: accessPoint
97 id: accessPoint
76 objectName: "accessPoint"
98 objectName: "accessPoint"
99+ highlightColor: backgroundColor
100+ enabled: menuData && menuData.sensitive || false
77
101
78 property QtObject menuData: null
102 property QtObject menuData: null
79 property var unityMenuModel: menuModel
103 property var unityMenuModel: menuModel
@@ -85,6 +109,7 @@ LocalComponents.Page {
85 }
109 }
86 readonly property bool secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
110 readonly property bool secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
87 readonly property bool adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
111 readonly property bool adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
112+ readonly property bool isConnected: menuData && menuData.label === networkInfo.accessPointName
88 property int signalStrength: strengthAction.valid ? strengthAction.state : 0
113 property int signalStrength: strengthAction.valid ? strengthAction.state : 0
89 property int menuIndex: -1
114 property int menuIndex: -1
90
115
@@ -95,33 +120,40 @@ LocalComponents.Page {
95 'x-canonical-wifi-ap-strength-action': 'string'});
120 'x-canonical-wifi-ap-strength-action': 'string'});
96 }
121 }
97
122
98− text: menuData && menuData.label || ""
123+ Image {
99− enabled: menuData && menuData.sensitive || false
124+ id: apIcon
100− __foregroundColor: textColor
125+ anchors {
101− showDivider: true
126+ left: parent.left
102− iconName: {
127+ verticalCenter: parent.verticalCenter
103− var imageName = "nm-no-connection";
128+ leftMargin: leftMargin
104−
105− if (adHoc) {
106− imageName = "nm-adhoc";
107− } else if (signalStrength == 0) {
108− imageName = "nm-signal-00";
109− } else if (signalStrength <= 25) {
110− imageName = "nm-signal-25";
111− } else if (signalStrength <= 50) {
112− imageName = "nm-signal-50";
113− } else if (signalStrength <= 75) {
114− imageName = "nm-signal-75";
115− } else if (signalStrength <= 100) {
116− imageName = "nm-signal-100";
117 }
129 }
130+ fillMode: Image.PreserveAspectFit
131+ height: apName.height
132+
133+ source: getAPIcon(accessPoint.adHoc, accessPoint.signalStrength, accessPoint.secure)
134+ }
118
135
119− if (secure) {
136+ Column {
120− imageName += "-secure";
137+ anchors.verticalCenter: parent.verticalCenter
138+ anchors.left: apIcon.right
139+ anchors.leftMargin: leftMargin
140+ Label {
141+ id: apName
142+ text: menuData && menuData.label || ""
143+ font.weight: accessPoint.isConnected ? Font.Normal : Font.Light
144+ fontSize: "medium"
145+ color: textColor
146+ }
147+ Label {
148+ id: connectedLabel
149+ text: i18n.tr("Connected")
150+ font.weight: Font.Light
151+ fontSize: "small"
152+ color: okColor
153+ visible: accessPoint.isConnected
121 }
154 }
122− return imageName;
123 }
155 }
124− iconFrame: false
156+
125 onClicked: unityMenuModel.activate(menuIndex);
157 onClicked: unityMenuModel.activate(menuIndex);
126
158
127 Component.onCompleted: {
159 Component.onCompleted: {