Merge pull request #2000 from notiant/patch-12

Use decimal units for disk space & network speeds
This commit is contained in:
Lysec
2026-02-28 22:54:23 +01:00
committed by GitHub
6 changed files with 25 additions and 23 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.memGb).toFixed(1)} 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.swapGb).toFixed(1)} GiB)`]);
}
// Network
+1
View File
@@ -582,6 +582,7 @@ PopupWindow {
Rectangle {
anchors.fill: parent
anchors.margins: border.width
color: Color.mSurfaceVariant
radius: Style.radiusS
border.color: Color.mOutline
@@ -33,7 +33,8 @@ ColumnLayout {
property string commitInfo: ""
readonly property bool isGitVersion: root.currentVersion.endsWith("-git")
readonly property int giga: (1024 * 1024 * 1024)
readonly property int gigaB: (1024 * 1024 * 1024)
readonly property int gigaD: (1000 * 1000 * 1000)
// Update status: compare versions (strip -git suffix for comparison)
readonly property string installedBase: root.currentVersion.replace("-git", "")
@@ -96,7 +97,7 @@ ColumnLayout {
version: UpdateService.currentVersion,
compositor: TelemetryService.getCompositorType(),
os: HostService.osPretty || "Unknown",
ramGb: Math.round((root.getModule("Memory")?.result?.total || 0) / root.giga),
ramGb: Math.round((root.getModule("Memory")?.result?.total || 0) / root.gigaB),
monitors: monitors,
ui: {
scaleRatio: Settings.data.general.scaleRatio,
@@ -140,7 +141,7 @@ ColumnLayout {
info += "GPU: " + gpu.result.map(g => g.name || "Unknown").join(", ") + "\n";
}
if (mem?.result) {
info += "Memory: " + SystemStatService.formatGigabytes(mem.result.total / root.giga) + "\n";
info += "Memory: " + (mem.result.total / root.gigaB).toFixed(1) + " GB \n";
}
if (wm?.result) {
info += "WM: " + (wm.result.prettyName || wm.result.processName || "N/A") + "\n";
@@ -734,9 +735,9 @@ ColumnLayout {
const mem = root.getModule("Memory");
if (!mem?.result)
return "N/A";
const used = SystemStatService.formatGigabytes(mem.result.used / root.giga);
const total = SystemStatService.formatGigabytes(mem.result.total / root.giga);
return used + " / " + total;
const used = (mem.result.used / root.gigaB).toFixed(1);
const total = (mem.result.total / root.gigaB).toFixed(1);
return used + " GiB / " + total + " GiB";
}
color: Color.mOnSurface
pointSize: sysInfo.textSize
@@ -758,9 +759,9 @@ ColumnLayout {
const rootDisk = disk.result.find(d => d.mountpoint === "/");
if (!rootDisk?.bytes)
return "N/A";
const used = SystemStatService.formatGigabytes(rootDisk.bytes.used / root.giga);
const total = SystemStatService.formatGigabytes(rootDisk.bytes.total / root.giga);
return used + " / " + total + " (" + rootDisk.filesystem + ")";
const used = (rootDisk.bytes.used / root.gigaD).toFixed(1);
const total = (rootDisk.bytes.total / root.gigaD).toFixed(1);
return used + " GB / " + total + " GB" + " (" + rootDisk.filesystem + ")";
}
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.memGb).toFixed(1)} 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.swapGb).toFixed(1)} / ${(SystemStatService.swapTotalGb).toFixed(1)} GiB`
pointSize: Style.fontSizeXS
color: Color.mOnSurface
Layout.fillWidth: true
+1 -1
View File
@@ -639,7 +639,7 @@ PopupWindow {
Rectangle {
anchors.fill: parent
anchors.margins: border.width / 2
anchors.margins: border.width
color: Color.mSurface
border.color: Color.mOutline
border.width: Style.borderS
+9 -9
View File
@@ -172,11 +172,11 @@ Singleton {
// Minimum floor of 1 MB/s so graph doesn't fluctuate at low speeds
readonly property real rxMaxSpeed: {
const max = Math.max(...rxSpeedHistory);
return Math.max(max, 1048576); // 1 MB/s floor
return Math.max(max, 1000000); // 1 MB/s floor
}
readonly property real txMaxSpeed: {
const max = Math.max(...txSpeedHistory);
return Math.max(max, 524288); // 512 KB/s floor
return Math.max(max, 512000); // 512 KB/s floor
}
// Ready-to-use ratios based on current maximums (0..1 range)
@@ -501,7 +501,7 @@ Singleton {
const newUsedGb = {};
const newSizeGb = {};
const newAvailableGb = {};
const bytesPerGb = 1024 * 1024 * 1024;
const bytesPerGb = 1000 * 1000 * 1000;
// Start from line 1 (skip header)
for (var i = 1; i < lines.length; i++) {
const parts = lines[i].trim().split(/\s+/);
@@ -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();