From f4b15f922ff0670d571ad90e61968adbee89761b Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Thu, 27 Oct 2022 20:09:46 -0400 Subject: [PATCH] components: Fix MarqueeLabel behaviour with new line characters --- components/mobileshell/qml/components/MarqueeLabel.qml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/mobileshell/qml/components/MarqueeLabel.qml b/components/mobileshell/qml/components/MarqueeLabel.qml index 4f3359e7..e3c28b4d 100644 --- a/components/mobileshell/qml/components/MarqueeLabel.qml +++ b/components/mobileshell/qml/components/MarqueeLabel.qml @@ -14,16 +14,17 @@ PlasmaComponents.Label { id: root required property string inputText + readonly property string filteredText: inputText.replace(/\n/g, ' ') // remove new line characters property int interval: PlasmaCore.Units.longDuration - readonly property int charactersOverflow: Math.ceil((txtMeter.advanceWidth - root.width) / (txtMeter.advanceWidth / inputText.length)) + readonly property int charactersOverflow: Math.ceil((txtMeter.advanceWidth - root.width) / (txtMeter.advanceWidth / filteredText.length)) property int step: 0 TextMetrics { id: txtMeter font: root.font - text: inputText + text: filteredText } Timer { @@ -42,7 +43,7 @@ PlasmaComponents.Label { paused = false; } } else { - step = (step + 1) % inputText.length; + step = (step + 1) % filteredText.length; if (step === charactersOverflow) { interval = PlasmaCore.Units.veryLongDuration * 3; paused = true; @@ -57,5 +58,5 @@ PlasmaComponents.Label { } } - text: inputText.substring(step, step + inputText.length - charactersOverflow) + text: filteredText.substring(step, step + filteredText.length - charactersOverflow) }