@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -14,11 +14,10 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−import QtQuick 2.0
17+import QtQuick 2.3
1818import QMenuModel 0.1 as QMenuModel
1919import QtSystemInfo 5.0
2020import Ubuntu.Components 1.2
21−import Ubuntu.Components.ListItems 0.1 as ListItem
2221import Ubuntu.Settings.Menus 0.1 as Menus
2322import ".." as LocalComponents
2423
@@ -38,6 +37,29 @@ LocalComponents.Page {
3837 return defaultValue;
3938 }
4039
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+
4163 QMenuModel.UnityMenuModel {
4264 id: menuModel
4365 busName: "com.canonical.indicator.network"
@@ -71,9 +93,11 @@ LocalComponents.Page {
7193
7294 Component {
7395 id: accessPointComponent
74− ListItem.Standard {
96+ ListItem {
7597 id: accessPoint
7698 objectName: "accessPoint"
99+ highlightColor: backgroundColor
100+ enabled: menuData && menuData.sensitive || false
77101
78102 property QtObject menuData: null
79103 property var unityMenuModel: menuModel
@@ -85,6 +109,7 @@ LocalComponents.Page {
85109 }
86110 readonly property bool secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
87111 readonly property bool adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
112+ readonly property bool isConnected: menuData && menuData.label === networkInfo.accessPointName
88113 property int signalStrength: strengthAction.valid ? strengthAction.state : 0
89114 property int menuIndex: -1
90115
@@ -95,33 +120,40 @@ LocalComponents.Page {
95120 'x-canonical-wifi-ap-strength-action': 'string'});
96121 }
97122
98− text: menuData && menuData.label || ""
99− enabled: menuData && menuData.sensitive || false
100− __foregroundColor: textColor
101− showDivider: true
102− iconName: {
103− var imageName = "nm-no-connection";
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";
123+ Image {
124+ id: apIcon
125+ anchors {
126+ left: parent.left
127+ verticalCenter: parent.verticalCenter
128+ leftMargin: leftMargin
117129 }
130+ fillMode: Image.PreserveAspectFit
131+ height: apName.height
132+
133+ source: getAPIcon(accessPoint.adHoc, accessPoint.signalStrength, accessPoint.secure)
134+ }
118135
119− if (secure) {
120− imageName += "-secure";
136+ Column {
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
121154 }
122− return imageName;
123155 }
124− iconFrame: false
156+
125157 onClicked: unityMenuModel.activate(menuIndex);
126158
127159 Component.onCompleted: {