diff --git a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy index 69e1e832..8180197b 100644 --- a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy +++ b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy @@ -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 + } } diff --git a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy index 3f6198f8..f93b479b 100644 --- a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy @@ -143,6 +143,9 @@ class MainFrameModel { @Observable boolean chatServerRunning @Observable Downloader downloader + + @Observable int downSpeed + @Observable int upSpeed private final Set downloadInfoHashes = new ConcurrentHashSet<>() @@ -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) @@ -682,7 +693,7 @@ class MainFrameModel { public int speed() { - if (finished) + if (finished) return 0 initIfNeeded() diff --git a/gui/griffon-app/resources/down_arrow.png b/gui/griffon-app/resources/down_arrow.png new file mode 100644 index 00000000..6f6d3f59 Binary files /dev/null and b/gui/griffon-app/resources/down_arrow.png differ diff --git a/gui/griffon-app/resources/up_arrow.png b/gui/griffon-app/resources/up_arrow.png new file mode 100644 index 00000000..7001e753 Binary files /dev/null and b/gui/griffon-app/resources/up_arrow.png differ diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index d973e37d..cf290c8b 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -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}) } }