plasma5-workspace/0001-OSD-Fix-size-calculation-for-progress-value.patch
Christophe Marin 106080a94a Accepting request 1101852 from home:Vogtinator:plasma5.27
- Add patch to fix line wrapping of "100 %" in OSDs (kde#469576):
  * 0001-OSD-Fix-size-calculation-for-progress-value.patch

OBS-URL: https://build.opensuse.org/request/show/1101852
OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks5/plasma5-workspace?expand=0&rev=705
2023-08-01 20:14:15 +00:00

64 lines
2.5 KiB
Diff

From 94b2c3d1d4a72d70d487513954601c2cf723e673 Mon Sep 17 00:00:00 2001
From: Kai Uwe Broulik <kde@privat.broulik.de>
Date: Tue, 1 Aug 2023 19:47:52 +0200
Subject: [PATCH] OSD: Fix size calculation for progress value
Use a common function for formatting the percent, so placeholder 100% label will
use the exact formatting used by the label next to the progress bar.
Also use font advanceWidth, which is the appropriate means of calculating the
bounding box of text in this case. Also ceil it to avoid subpixel alignment.
And to be absolutely sure disable word wrapping.
BUG: 469576
(cherry picked from commit 9737efa79440b65db303030f34f0039f1c9cd6a0)
---
lookandfeel/org.kde.breeze/contents/osd/OsdItem.qml | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lookandfeel/org.kde.breeze/contents/osd/OsdItem.qml b/lookandfeel/org.kde.breeze/contents/osd/OsdItem.qml
index fa892cb23..bc60efc15 100644
--- a/lookandfeel/org.kde.breeze/contents/osd/OsdItem.qml
+++ b/lookandfeel/org.kde.breeze/contents/osd/OsdItem.qml
@@ -26,6 +26,10 @@ RowLayout {
// false for displaying the value as normal text
property bool showingProgress: false
+ function formatPercent(number) {
+ return i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Percentage value", "%1%", number);
+ }
+
spacing: PlasmaCore.Units.smallSpacing
Layout.preferredWidth: Math.max(Math.min(Screen.desktopAvailableWidth / 2, implicitWidth), PlasmaCore.Units.gridUnit * 15)
@@ -63,7 +67,7 @@ RowLayout {
// to the maximum width to avoid the progress bad resizing itself
TextMetrics {
id: widestLabelSize
- text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "100%")
+ text: formatPercent(100)
font: percentageLabel.font
}
@@ -71,13 +75,14 @@ RowLayout {
PlasmaExtra.Heading {
id: percentageLabel
Layout.fillHeight: true
- Layout.preferredWidth: widestLabelSize.width
+ Layout.preferredWidth: Math.ceil(widestLabelSize.advanceWidth)
Layout.rightMargin: PlasmaCore.Units.smallSpacing
Layout.alignment: Qt.AlignVCenter
level: 3
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
- text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Percentage value", "%1%", progressBar.value)
+ text: formatPercent(progressBar.value)
+ wrapMode: Text.NoWrap
visible: showingProgress
// Display a subtle visual indication that the volume might be
// dangerously high
--
2.41.0