Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/ConnectionItem.qml
Show All 40 Lines | 38 | (Type == PlasmaNM.Enums.Wired || | |||
---|---|---|---|---|---|
41 | Type == PlasmaNM.Enums.Cdma) | 41 | Type == PlasmaNM.Enums.Cdma) | ||
42 | property bool visibleDetails: false | 42 | property bool visibleDetails: false | ||
43 | property bool visiblePasswordDialog: false | 43 | property bool visiblePasswordDialog: false | ||
44 | 44 | | |||
45 | checked: connectionItem.containsMouse | 45 | checked: connectionItem.containsMouse | ||
46 | enabled: true | 46 | enabled: true | ||
47 | height: expanded ? baseHeight + separator.height + expandableComponentLoader.height + (2 * Math.round(units.gridUnit / 3)) : baseHeight | 47 | height: expanded ? baseHeight + separator.height + expandableComponentLoader.height + (2 * Math.round(units.gridUnit / 3)) : baseHeight | ||
48 | 48 | | |||
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 { | 49 | ColumnLayout { | ||
61 | anchors.fill: parent | 50 | anchors.fill: parent | ||
62 | 51 | | |||
63 | RowLayout { | 52 | RowLayout { | ||
64 | Layout.fillWidth: true | 53 | Layout.fillWidth: true | ||
65 | spacing: Math.round(units.gridUnit / 2) | 54 | spacing: Math.round(units.gridUnit / 2) | ||
66 | 55 | | |||
67 | PlasmaCore.SvgItem { | 56 | PlasmaCore.SvgItem { | ||
Show All 27 Lines | 69 | ColumnLayout { | |||
95 | PlasmaComponents.Label { | 84 | PlasmaComponents.Label { | ||
96 | id: connectionStatusLabel | 85 | id: connectionStatusLabel | ||
97 | Layout.fillWidth: true | 86 | Layout.fillWidth: true | ||
98 | height: paintedHeight | 87 | height: paintedHeight | ||
99 | elide: Text.ElideRight | 88 | elide: Text.ElideRight | ||
100 | font.pointSize: theme.smallestFont.pointSize | 89 | font.pointSize: theme.smallestFont.pointSize | ||
101 | opacity: 0.6 | 90 | opacity: 0.6 | ||
102 | text: itemText() | 91 | text: itemText() | ||
92 | onVisibleChanged: { | ||||
93 | connectionModel.setDeviceStatisticsRefreshRateMs(DevicePath, visible ? 2000 : 0) | ||||
94 | } | ||||
103 | } | 95 | } | ||
104 | } | 96 | } | ||
105 | 97 | | |||
106 | PlasmaComponents.BusyIndicator { | 98 | PlasmaComponents.BusyIndicator { | ||
107 | id: connectingIndicator | 99 | id: connectingIndicator | ||
108 | Layout.alignment: Qt.AlignVCenter | Qt.AlignRight | 100 | Layout.alignment: Qt.AlignVCenter | Qt.AlignRight | ||
109 | Layout.fillHeight: true | 101 | Layout.fillHeight: true | ||
110 | running: plasmoid.expanded && !stateChangeButton.visible && ConnectionState == PlasmaNM.Enums.Activating | 102 | running: plasmoid.expanded && !stateChangeButton.visible && ConnectionState == PlasmaNM.Enums.Activating | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 145 | PlasmaComponents.TabBar { | |||
154 | id: detailsTabBar | 146 | id: detailsTabBar | ||
155 | 147 | | |||
156 | anchors { | 148 | anchors { | ||
157 | left: parent.left | 149 | left: parent.left | ||
158 | right: parent.right | 150 | right: parent.right | ||
159 | top: parent.top | 151 | top: parent.top | ||
160 | } | 152 | } | ||
161 | height: visible ? implicitHeight : 0 | 153 | height: visible ? implicitHeight : 0 | ||
162 | visible: showSpeed && dataSource.data && dataSource.data[dataSource.downloadSource] && dataSource.data[dataSource.uploadSource] | 154 | visible: showSpeed | ||
163 | 155 | | |||
164 | PlasmaComponents.TabButton { | 156 | PlasmaComponents.TabButton { | ||
165 | id: speedTabButton | 157 | id: speedTabButton | ||
166 | text: i18n("Speed") | 158 | text: i18n("Speed") | ||
167 | } | 159 | } | ||
168 | 160 | | |||
169 | PlasmaComponents.TabButton { | 161 | PlasmaComponents.TabButton { | ||
170 | id: detailsTabButton | 162 | id: detailsTabButton | ||
Show All 21 Lines | |||||
192 | 184 | | |||
193 | TrafficMonitor { | 185 | TrafficMonitor { | ||
194 | anchors { | 186 | anchors { | ||
195 | left: parent.left | 187 | left: parent.left | ||
196 | right: parent.right | 188 | right: parent.right | ||
197 | top: detailsTabBar.visible ? detailsTabBar.bottom : parent.top | 189 | top: detailsTabBar.visible ? detailsTabBar.bottom : parent.top | ||
198 | topMargin: Math.round(units.gridUnit / 3) | 190 | topMargin: Math.round(units.gridUnit / 3) | ||
199 | } | 191 | } | ||
200 | dataEngine: dataSource | 192 | rxBytes: RxBytes | ||
201 | deviceName: DeviceName | 193 | txBytes: TxBytes | ||
194 | interval: 2000 | ||||
202 | visible: detailsTabBar.currentTab == speedTabButton | 195 | visible: detailsTabBar.currentTab == speedTabButton | ||
203 | } | 196 | } | ||
204 | } | 197 | } | ||
205 | } | 198 | } | ||
206 | 199 | | |||
207 | Component { | 200 | Component { | ||
208 | id: passwordDialogComponent | 201 | id: passwordDialogComponent | ||
209 | 202 | | |||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 298 | } else if (ConnectionState == PlasmaNM.Enums.Deactivating) { | |||
308 | else | 301 | else | ||
309 | return DeviceState | 302 | return DeviceState | ||
310 | } else if (ConnectionState == PlasmaNM.Enums.Deactivated) { | 303 | } else if (ConnectionState == PlasmaNM.Enums.Deactivated) { | ||
311 | var result = LastUsed | 304 | var result = LastUsed | ||
312 | if (SecurityType > PlasmaNM.Enums.NoneSecurity) | 305 | if (SecurityType > PlasmaNM.Enums.NoneSecurity) | ||
313 | result += ", " + SecurityTypeString | 306 | result += ", " + SecurityTypeString | ||
314 | return result | 307 | return result | ||
315 | } else if (ConnectionState == PlasmaNM.Enums.Activated) { | 308 | } else if (ConnectionState == PlasmaNM.Enums.Activated) { | ||
316 | if (showSpeed && dataSource.data && dataSource.data[dataSource.downloadSource] && dataSource.data[dataSource.uploadSource]) { | 309 | if (showSpeed) { | ||
317 | var downloadColor = theme.highlightColor | 310 | var downloadColor = theme.highlightColor | ||
318 | // cycle upload color by 180 degrees | 311 | // cycle upload color by 180 degrees | ||
319 | var uploadColor = Qt.hsva((downloadColor.hsvHue + 0.5) % 1, downloadColor.hsvSaturation, downloadColor.hsvValue, downloadColor.a) | 312 | var uploadColor = Qt.hsva((downloadColor.hsvHue + 0.5) % 1, downloadColor.hsvSaturation, downloadColor.hsvValue, downloadColor.a) | ||
320 | 313 | | |||
321 | return i18n("Connected, <font color='%1'>⬇</font> %2/s, <font color='%3'>⬆</font> %4/s", | 314 | return i18n("Connected, <font color='%1'>⬇</font> %2, <font color='%3'>⬆</font> %4", | ||
322 | downloadColor, | 315 | downloadColor, | ||
323 | KCoreAddons.Format.formatByteSize(dataSource.data[dataSource.downloadSource].value * 1024 || 0), | 316 | KCoreAddons.Format.formatByteSize(RxBytes), | ||
324 | uploadColor, | 317 | uploadColor, | ||
325 | KCoreAddons.Format.formatByteSize(dataSource.data[dataSource.uploadSource].value * 1024 || 0)) | 318 | KCoreAddons.Format.formatByteSize(TxBytes)) | ||
326 | } else { | 319 | } else { | ||
327 | return i18n("Connected") | 320 | return i18n("Connected") | ||
328 | } | 321 | } | ||
329 | } | 322 | } | ||
330 | } | 323 | } | ||
331 | 324 | | |||
332 | onActivatingChanged: { | 325 | onActivatingChanged: { | ||
333 | if (ConnectionState == PlasmaNM.Enums.Activating) { | 326 | if (ConnectionState == PlasmaNM.Enums.Activating) { | ||
Show All 25 Lines |