use decimal units for network speed

This commit is contained in:
notiant
2026-02-28 18:01:27 +01:00
committed by GitHub
parent 0b6495b60f
commit 3cd3c92edd
4 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -110,11 +110,11 @@ Item {
}
// Memory
rows.push([I18n.tr("common.memory"), `${Math.round(SystemStatService.memPercent)}% (${SystemStatService.formatGigabytes(SystemStatService.memGb).replace(/[^0-9.]/g, "") + " GB"})`]);
rows.push([I18n.tr("common.memory"), `${Math.round(SystemStatService.memPercent)}% (${SystemStatService.formatGigabytes(SystemStatService.memGb).replace(/[^0-9.]/g, "") + " GiB"})`]);
// Swap (if available)
if (SystemStatService.swapTotalGb > 0) {
rows.push([I18n.tr("bar.system-monitor.swap-usage-label"), `${Math.round(SystemStatService.swapPercent)}% (${SystemStatService.formatGigabytes(SystemStatService.swapGb).replace(/[^0-9.]/g, "") + " GB"})`]);
rows.push([I18n.tr("bar.system-monitor.swap-usage-label"), `${Math.round(SystemStatService.swapPercent)}% (${SystemStatService.formatGigabytes(SystemStatService.swapGb).replace(/[^0-9.]/g, "") + " GiB"})`]);
}
// Network
@@ -737,7 +737,7 @@ ColumnLayout {
return "N/A";
const used = (mem.result.used / root.gigaB).toFixed(1);
const total = (mem.result.total / root.gigaB).toFixed(1);
return used + " GB / " + total + " GB";
return used + " GiB / " + total + " GiB";
}
color: Color.mOnSurface
pointSize: sysInfo.textSize
@@ -165,7 +165,7 @@ SmartPanel {
}
NText {
text: `${Math.round(SystemStatService.memPercent)}% (${SystemStatService.formatGigabytes(SystemStatService.memGb).replace(/[^0-9.]/g, "")} GB)`
text: `${Math.round(SystemStatService.memPercent)}% (${SystemStatService.formatGigabytes(SystemStatService.memGb).replace(/[^0-9.]/g, "")} GiB)`
pointSize: Style.fontSizeXS
color: Color.mPrimary
font.family: Settings.data.ui.fontFixed
@@ -386,7 +386,7 @@ SmartPanel {
}
NText {
text: `${SystemStatService.formatGigabytes(SystemStatService.swapGb).replace(/[^0-9.]/g, "")} / ${SystemStatService.formatGigabytes(SystemStatService.swapTotalGb).replace(/[^0-9.]/g, "")} GB`
text: `${SystemStatService.formatGigabytes(SystemStatService.swapGb).replace(/[^0-9.]/g, "")} / ${SystemStatService.formatGigabytes(SystemStatService.swapTotalGb).replace(/[^0-9.]/g, "")} GiB`
pointSize: Style.fontSizeXS
color: Color.mOnSurface
Layout.fillWidth: true
+6 -6
View File
@@ -1209,11 +1209,11 @@ Singleton {
// Helper function to format network speeds
function formatSpeed(bytesPerSecond) {
const units = ["KB", "MB", "GB"];
let value = bytesPerSecond / 1024;
let value = bytesPerSecond / 1000;
let unitIndex = 0;
while (value >= 1024 && unitIndex < units.length - 1) {
value /= 1024;
while (value >= 1000 && unitIndex < units.length - 1) {
value /= 1000;
unitIndex++;
}
@@ -1232,13 +1232,13 @@ Singleton {
const units = ["", "K", "M", "G"];
let value = bytesPerSecond;
let unitIndex = 0;
while (value >= 1024 && unitIndex < units.length - 1) {
value = value / 1024.0;
while (value >= 1000 && unitIndex < units.length - 1) {
value = value / 1000.0;
unitIndex++;
}
// Promote at ~100 of current unit (e.g., 100k -> ~0.1M shown as 0.1M or 0M if rounded)
if (unitIndex < units.length - 1 && value >= 100) {
value = value / 1024.0;
value = value / 1000.0;
unitIndex++;
}
const display = Math.round(value).toString();