Skip to content

Commit

Permalink
perf(data): connect source when is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
orblazer committed Oct 20, 2021
1 parent fc4856d commit 8fab442
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ Item {
property double downloadProportion: 0
property double uploadProportion: 0

connectedSources: [memFree, memUsed, memApplication, swapUsed, swapFree, averageClock, totalLoad]

onNewData: {
if (data.value === undefined) {
return
Expand Down Expand Up @@ -156,25 +154,39 @@ Item {
}
}
onSourceAdded: {
var match
if (plasmoid.configuration.networkSensorInterface === '') {
match = source.match(networkRegex)
} else {
match = source.match(new RegExp('/^network\/interfaces\/' +
plasmoid.configuration.networkSensorInterface.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') +
'\/(transmitter|receiver)\/data$/'))
if (showCpuMonitor && (source === totalLoad)) {
dataSource.connectSource(source)
}

if (match == null) {
return
if (showClock && (source === averageClock)) {
dataSource.connectSource(source)
}

if (match[1] === 'receiver') {
downloadTotal = source
} else {
uploadTotal = source
if (showRamMonitor && (source === memFree || source === memUsed || source === memApplication)) {
dataSource.connectSource(source)
}
if (showSwapGraph && (source === swapUsed || source === swapFree)) {
dataSource.connectSource(source)
}
if (showNetMonitor) {
var match
if (plasmoid.configuration.networkSensorInterface === '') {
match = source.match(networkRegex)
} else {
match = source.match(new RegExp('/^network\/interfaces\/' +
plasmoid.configuration.networkSensorInterface.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') +
'\/(transmitter|receiver)\/data$/'))
}

if (match == null) {
return
}

if (match[1] === 'receiver') {
downloadTotal = source
} else {
uploadTotal = source
}
dataSource.connectSource(source)
}
dataSource.connectSource(source)
}
interval: 1000 * plasmoid.configuration.updateInterval
}
Expand Down

0 comments on commit 8fab442

Please sign in to comment.