From 758f2f2e554be5b13def1fbe6798843f4acb228a Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Mon, 15 Sep 2025 13:43:58 +0200 Subject: [PATCH] SystemMonitor: fix network stats, move text above storage icon (vertical bar) --- Modules/Bar/Widgets/SystemMonitor.qml | 72 +++++++++++++++++---------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/Modules/Bar/Widgets/SystemMonitor.qml b/Modules/Bar/Widgets/SystemMonitor.qml index 9d97f7e..37cdc42 100644 --- a/Modules/Bar/Widgets/SystemMonitor.qml +++ b/Modules/Bar/Widgets/SystemMonitor.qml @@ -43,6 +43,26 @@ Rectangle { radius: Math.round(Style.radiusM * scaling) color: Color.mSurfaceVariant + // Compact speed formatter for vertical bar display + function formatCompactSpeed(bytesPerSecond) { + if (!bytesPerSecond || bytesPerSecond <= 0) + return "0" + const units = ["", "k", "M", "G"] + let value = bytesPerSecond + let unitIndex = 0 + while (value >= 1024 && unitIndex < units.length - 1) { + value = value / 1024.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 + unitIndex++ + } + const display = (value >= 10) ? Math.round(value).toString() : value.toFixed(1) + return display + units[unitIndex] + } + // Horizontal layout for top/bottom bars RowLayout { id: horizontalLayout @@ -347,21 +367,21 @@ Rectangle { anchors.centerIn: parent spacing: Style.marginXXS * scaling + NText { + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + text: formatCompactSpeed(SystemStatService.rxSpeed) + font.family: Settings.data.ui.fontFixed + font.pointSize: Style.fontSizeXXS * scaling + font.weight: Style.fontWeightMedium + color: Color.mPrimary + } + NIcon { icon: "download-speed" font.pointSize: Style.fontSizeS * scaling anchors.horizontalCenter: parent.horizontalCenter } - - NText { - text: SystemStatService.formatSpeed(SystemStatService.rxSpeed) - font.family: Settings.data.ui.fontFixed - font.pointSize: Style.fontSizeXXS * scaling - font.weight: Style.fontWeightMedium - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - color: Color.mPrimary - } } } @@ -377,21 +397,21 @@ Rectangle { anchors.centerIn: parent spacing: Style.marginXXS * scaling + NText { + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + text: formatCompactSpeed(SystemStatService.txSpeed) + font.family: Settings.data.ui.fontFixed + font.pointSize: Style.fontSizeXXS * scaling + font.weight: Style.fontWeightMedium + color: Color.mPrimary + } + NIcon { icon: "upload-speed" font.pointSize: Style.fontSizeS * scaling anchors.horizontalCenter: parent.horizontalCenter } - - NText { - text: SystemStatService.formatSpeed(SystemStatService.txSpeed) - font.family: Settings.data.ui.fontFixed - font.pointSize: Style.fontSizeXXS * scaling - font.weight: Style.fontWeightMedium - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - color: Color.mPrimary - } } } @@ -407,12 +427,6 @@ Rectangle { anchors.centerIn: parent spacing: Style.marginXXS * scaling - NIcon { - icon: "storage" - font.pointSize: Style.fontSizeS * scaling - Layout.alignment: Qt.AlignHCenter - } - NText { text: `${SystemStatService.diskPercent}%` font.family: Settings.data.ui.fontFixed @@ -422,6 +436,12 @@ Rectangle { horizontalAlignment: Text.AlignHCenter color: Color.mPrimary } + + NIcon { + icon: "storage" + font.pointSize: Style.fontSizeS * scaling + Layout.alignment: Qt.AlignHCenter + } } } }