Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/ConnectionItem.qml
Show All 28 Lines | 28 | PlasmaComponents.ListItem { | |||
---|---|---|---|---|---|
29 | id: connectionItem | 29 | id: connectionItem | ||
30 | 30 | | |||
31 | property bool activating: ConnectionState == PlasmaNM.Enums.Activating | 31 | property bool activating: ConnectionState == PlasmaNM.Enums.Activating | ||
32 | property int baseHeight: Math.max(units.iconSizes.medium, connectionNameLabel.height + connectionStatusLabel.height) + Math.round(units.gridUnit / 2) | 32 | property int baseHeight: Math.max(units.iconSizes.medium, connectionNameLabel.height + connectionStatusLabel.height) + Math.round(units.gridUnit / 2) | ||
33 | property bool expanded: visibleDetails || visiblePasswordDialog | 33 | property bool expanded: visibleDetails || visiblePasswordDialog | ||
34 | property bool predictableWirelessPassword: !Uuid && Type == PlasmaNM.Enums.Wireless && | 34 | property bool predictableWirelessPassword: !Uuid && Type == PlasmaNM.Enums.Wireless && | ||
35 | (SecurityType == PlasmaNM.Enums.StaticWep || SecurityType == PlasmaNM.Enums.WpaPsk || | 35 | (SecurityType == PlasmaNM.Enums.StaticWep || SecurityType == PlasmaNM.Enums.WpaPsk || | ||
36 | SecurityType == PlasmaNM.Enums.Wpa2Psk) | 36 | SecurityType == PlasmaNM.Enums.Wpa2Psk) | ||
37 | property bool showSpeed: ConnectionState == PlasmaNM.Enums.Activated && | 37 | property bool showSpeed: plasmoid.expanded && | ||
38 | ConnectionState == PlasmaNM.Enums.Activated && | ||||
38 | (Type == PlasmaNM.Enums.Wired || | 39 | (Type == PlasmaNM.Enums.Wired || | ||
39 | Type == PlasmaNM.Enums.Wireless || | 40 | Type == PlasmaNM.Enums.Wireless || | ||
40 | Type == PlasmaNM.Enums.Gsm || | 41 | Type == PlasmaNM.Enums.Gsm || | ||
41 | Type == PlasmaNM.Enums.Cdma) | 42 | Type == PlasmaNM.Enums.Cdma) | ||
42 | property bool visibleDetails: false | 43 | property bool visibleDetails: false | ||
43 | property bool visiblePasswordDialog: false | 44 | property bool visiblePasswordDialog: false | ||
44 | 45 | | |||
45 | checked: connectionItem.containsMouse | 46 | checked: connectionItem.containsMouse | ||
46 | enabled: true | 47 | enabled: true | ||
47 | height: expanded ? baseHeight + separator.height + expandableComponentLoader.height + (2 * Math.round(units.gridUnit / 3)) : baseHeight | 48 | height: expanded ? baseHeight + separator.height + expandableComponentLoader.height + (2 * Math.round(units.gridUnit / 3)) : baseHeight | ||
48 | 49 | | |||
49 | PlasmaCore.DataSource { | | |||
50 | id: dataSource | | |||
51 | | ||||
52 | property string downloadSource: "network/interfaces/" + DeviceName + "/receiver/data" | | |||
53 | property string uploadSource: "network/interfaces/" + DeviceName + "/transmitter/data" | | |||
54 | | ||||
55 | connectedSources: showSpeed && plasmoid.expanded ? [downloadSource, uploadSource] : [] | | |||
56 | engine: "systemmonitor" | | |||
57 | interval: 2000 | | |||
58 | } | | |||
59 | | ||||
60 | ColumnLayout { | 50 | ColumnLayout { | ||
61 | anchors.fill: parent | 51 | anchors.fill: parent | ||
62 | 52 | | |||
63 | RowLayout { | 53 | RowLayout { | ||
64 | Layout.fillWidth: true | 54 | Layout.fillWidth: true | ||
65 | spacing: Math.round(units.gridUnit / 2) | 55 | spacing: Math.round(units.gridUnit / 2) | ||
66 | 56 | | |||
67 | PlasmaCore.SvgItem { | 57 | PlasmaCore.SvgItem { | ||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 143 | PlasmaComponents.TabBar { | |||
154 | id: detailsTabBar | 144 | id: detailsTabBar | ||
155 | 145 | | |||
156 | anchors { | 146 | anchors { | ||
157 | left: parent.left | 147 | left: parent.left | ||
158 | right: parent.right | 148 | right: parent.right | ||
159 | top: parent.top | 149 | top: parent.top | ||
160 | } | 150 | } | ||
161 | height: visible ? implicitHeight : 0 | 151 | height: visible ? implicitHeight : 0 | ||
162 | visible: showSpeed && dataSource.data && dataSource.data[dataSource.downloadSource] && dataSource.data[dataSource.uploadSource] | 152 | visible: showSpeed | ||
163 | 153 | | |||
164 | PlasmaComponents.TabButton { | 154 | PlasmaComponents.TabButton { | ||
165 | id: speedTabButton | 155 | id: speedTabButton | ||
166 | text: i18n("Speed") | 156 | text: i18n("Speed") | ||
167 | } | 157 | } | ||
168 | 158 | | |||
169 | PlasmaComponents.TabButton { | 159 | PlasmaComponents.TabButton { | ||
170 | id: detailsTabButton | 160 | id: detailsTabButton | ||
Show All 21 Lines | |||||
192 | 182 | | |||
193 | TrafficMonitor { | 183 | TrafficMonitor { | ||
194 | anchors { | 184 | anchors { | ||
195 | left: parent.left | 185 | left: parent.left | ||
196 | right: parent.right | 186 | right: parent.right | ||
197 | top: detailsTabBar.visible ? detailsTabBar.bottom : parent.top | 187 | top: detailsTabBar.visible ? detailsTabBar.bottom : parent.top | ||
198 | topMargin: Math.round(units.gridUnit / 3) | 188 | topMargin: Math.round(units.gridUnit / 3) | ||
199 | } | 189 | } | ||
200 | dataEngine: dataSource | 190 | rxBytes: RxBytes | ||
201 | deviceName: DeviceName | 191 | txBytes: TxBytes | ||
192 | interval: 2000 | ||||
202 | visible: detailsTabBar.currentTab == speedTabButton | 193 | visible: detailsTabBar.currentTab == speedTabButton | ||
203 | } | 194 | } | ||
204 | } | 195 | } | ||
205 | } | 196 | } | ||
206 | 197 | | |||
207 | Component { | 198 | Component { | ||
208 | id: passwordDialogComponent | 199 | id: passwordDialogComponent | ||
209 | 200 | | |||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 296 | } else if (ConnectionState == PlasmaNM.Enums.Deactivating) { | |||
308 | else | 299 | else | ||
309 | return DeviceState | 300 | return DeviceState | ||
310 | } else if (ConnectionState == PlasmaNM.Enums.Deactivated) { | 301 | } else if (ConnectionState == PlasmaNM.Enums.Deactivated) { | ||
311 | var result = LastUsed | 302 | var result = LastUsed | ||
312 | if (SecurityType > PlasmaNM.Enums.NoneSecurity) | 303 | if (SecurityType > PlasmaNM.Enums.NoneSecurity) | ||
313 | result += ", " + SecurityTypeString | 304 | result += ", " + SecurityTypeString | ||
314 | return result | 305 | return result | ||
315 | } else if (ConnectionState == PlasmaNM.Enums.Activated) { | 306 | } else if (ConnectionState == PlasmaNM.Enums.Activated) { | ||
316 | if (showSpeed && dataSource.data && dataSource.data[dataSource.downloadSource] && dataSource.data[dataSource.uploadSource]) { | 307 | if (showSpeed) { | ||
317 | var downloadColor = theme.highlightColor | 308 | var downloadColor = theme.highlightColor | ||
318 | // cycle upload color by 180 degrees | 309 | // cycle upload color by 180 degrees | ||
319 | var uploadColor = Qt.hsva((downloadColor.hsvHue + 0.5) % 1, downloadColor.hsvSaturation, downloadColor.hsvValue, downloadColor.a) | 310 | var uploadColor = Qt.hsva((downloadColor.hsvHue + 0.5) % 1, downloadColor.hsvSaturation, downloadColor.hsvValue, downloadColor.a) | ||
320 | 311 | | |||
321 | return i18n("Connected, <font color='%1'>⬇</font> %2/s, <font color='%3'>⬆</font> %4/s", | 312 | return i18n("Connected, <font color='%1'>⬇</font> %2, <font color='%3'>⬆</font> %4", | ||
322 | downloadColor, | 313 | downloadColor, | ||
323 | KCoreAddons.Format.formatByteSize(dataSource.data[dataSource.downloadSource].value * 1024 || 0), | 314 | KCoreAddons.Format.formatByteSize(RxBytes), | ||
324 | uploadColor, | 315 | uploadColor, | ||
325 | KCoreAddons.Format.formatByteSize(dataSource.data[dataSource.uploadSource].value * 1024 || 0)) | 316 | KCoreAddons.Format.formatByteSize(TxBytes)) | ||
326 | } else { | 317 | } else { | ||
327 | return i18n("Connected") | 318 | return i18n("Connected") | ||
328 | } | 319 | } | ||
329 | } | 320 | } | ||
330 | } | 321 | } | ||
331 | 322 | | |||
323 | onShowSpeedChanged: { | ||||
324 | connectionModel.setDeviceStatisticsRefreshRateMs(DevicePath, showSpeed ? 2000 : 0) | ||||
325 | } | ||||
326 | | ||||
332 | onActivatingChanged: { | 327 | onActivatingChanged: { | ||
333 | if (ConnectionState == PlasmaNM.Enums.Activating) { | 328 | if (ConnectionState == PlasmaNM.Enums.Activating) { | ||
334 | ListView.view.positionViewAtBeginning() | 329 | ListView.view.positionViewAtBeginning() | ||
335 | } | 330 | } | ||
336 | } | 331 | } | ||
337 | 332 | | |||
338 | onClicked: { | 333 | onClicked: { | ||
339 | if (visiblePasswordDialog) { | 334 | if (visiblePasswordDialog) { | ||
Show All 19 Lines |