show total up & down speeds

pull/53/head
Zlatin Balevsky 2020-10-11 17:42:47 +01:00
parent 01c9c0ee1c
commit 9fc2a0c4c5
No known key found for this signature in database
GPG Key ID: A72832072D525E41
5 changed files with 32 additions and 2 deletions

View File

@ -255,4 +255,10 @@ public class DownloadManager {
public boolean isDownloading(InfoHash infoHash) {
downloaders.containsKey(infoHash)
}
public int totalDownloadSpeed() {
int total = 0
downloaders.values().each { total += it.speed() }
total
}
}

View File

@ -144,6 +144,9 @@ class MainFrameModel {
@Observable Downloader downloader
@Observable int downSpeed
@Observable int upSpeed
private final Set<InfoHash> downloadInfoHashes = new ConcurrentHashSet<>()
@Observable volatile Core core
@ -208,6 +211,14 @@ class MainFrameModel {
updateTablePreservingSelection("downloads-table")
updateTablePreservingSelection("trusted-table")
updateTablePreservingSelection("distrusted-table")
int totalUpload = 0
uploads.each {
totalUpload += it.speed()
}
upSpeed = totalUpload
if (core != null)
downSpeed = core.downloadManager.totalDownloadSpeed()
}
}, 1000, 1000)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -593,8 +593,21 @@ class MainFrameView {
button(text : trans("COPY_SHORT"), constraints : gbc(gridx:1, gridy:0), copyShortAction)
button(text : trans("COPY_FULL"), constraints : gbc(gridx:2, gridy:0), copyFullAction)
}
panel (constraints : BorderLayout.CENTER) {
gridBagLayout()
panel (constraints : gbc(gridx : 0, gridy : 0)){
borderLayout()
label(icon : imageIcon('/down_arrow.png'), constraints : BorderLayout.CENTER)
label(text : bind { DataHelper.formatSize2Decimal(model.downSpeed, false) + trans("B_SEC") }, constraints : BorderLayout.EAST)
}
panel (constraints : gbc(gridx: 1, gridy : 0)){
borderLayout()
label(icon : imageIcon('/up_arrow.png'), constraints : BorderLayout.CENTER)
label(text : bind { DataHelper.formatSize2Decimal(model.upSpeed, false) + trans("B_SEC") }, constraints : BorderLayout.EAST)
}
}
panel (constraints : BorderLayout.EAST) {
label(trans("CONNECTIONS") + ":")
label(" " + trans("CONNECTIONS") + ":")
label(text : bind {model.connections})
}
}