From cb01563ba8e24bbd8177099782d6ae78ff037064 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Tue, 12 Aug 2025 22:09:20 +0700 Subject: [PATCH] bar: make resource numbers have fixed width --- .../quickshell/ii/modules/bar/Resource.qml | 20 +++++++++++++++---- .../quickshell/ii/modules/bar/Resources.qml | 4 ++-- .../common/widgets/StyledProgressBar.qml | 1 - 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.config/quickshell/ii/modules/bar/Resource.qml b/.config/quickshell/ii/modules/bar/Resource.qml index 65b22e15d..9b675cbcc 100644 --- a/.config/quickshell/ii/modules/bar/Resource.qml +++ b/.config/quickshell/ii/modules/bar/Resource.qml @@ -32,7 +32,7 @@ Item { RowLayout { id: resourceRowLayout - spacing: 4 + spacing: 2 x: shown ? 0 : -resourceRowLayout.width CircularProgress { @@ -53,10 +53,22 @@ Item { } } - StyledText { + Item { Layout.alignment: Qt.AlignVCenter - color: Appearance.colors.colOnLayer1 - text: `${Math.round(percentage * 100)}` + implicitWidth: fullPercentageTextMetrics.width + implicitHeight: percentageText.implicitHeight + + TextMetrics { + id: fullPercentageTextMetrics + text: "100" + } + + StyledText { + id: percentageText + anchors.centerIn: parent + color: Appearance.colors.colOnLayer1 + text: `${Math.round(percentage * 100).toString()}` + } } Behavior on x { diff --git a/.config/quickshell/ii/modules/bar/Resources.qml b/.config/quickshell/ii/modules/bar/Resources.qml index 8d39de037..23c897c8b 100644 --- a/.config/quickshell/ii/modules/bar/Resources.qml +++ b/.config/quickshell/ii/modules/bar/Resources.qml @@ -39,7 +39,7 @@ Item { shown: (Config.options.bar.resources.alwaysShowSwap && percentage > 0) || (MprisController.activePlayer?.trackTitle == null) || root.alwaysShowAllResources - Layout.leftMargin: shown ? 4 : 0 + Layout.leftMargin: shown ? 6 : 0 tooltipHeaderIcon: "swap_horiz" tooltipHeaderText: Translation.tr("Swap usage") @@ -58,7 +58,7 @@ Item { shown: Config.options.bar.resources.alwaysShowCpu || !(MprisController.activePlayer?.trackTitle?.length > 0) || root.alwaysShowAllResources - Layout.leftMargin: shown ? 4 : 0 + Layout.leftMargin: shown ? 6 : 0 tooltipHeaderIcon: "settings_slow_motion" tooltipHeaderText: Translation.tr("CPU usage") diff --git a/.config/quickshell/ii/modules/common/widgets/StyledProgressBar.qml b/.config/quickshell/ii/modules/common/widgets/StyledProgressBar.qml index fa1cd0be7..8197b29f9 100644 --- a/.config/quickshell/ii/modules/common/widgets/StyledProgressBar.qml +++ b/.config/quickshell/ii/modules/common/widgets/StyledProgressBar.qml @@ -33,7 +33,6 @@ ProgressBar { } background: Item { - anchors.fill: parent implicitHeight: valueBarHeight implicitWidth: valueBarWidth }