mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
components: fix MarqueeLabel
This commit is contained in:
parent
6e075b9db7
commit
e0ce7f3cec
1 changed files with 8 additions and 11 deletions
|
|
@ -10,25 +10,22 @@ import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.plasma.components 3.0 as PlasmaComponents
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a simple marquee (flowing) label based on PlasmaComponents Label.Array()
|
* This is a simple marquee (flowing) label based on PlasmaComponents Label.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
PlasmaComponents.Label {
|
PlasmaComponents.Label {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property string inputText
|
required property string inputText
|
||||||
required property real rightPadding
|
|
||||||
|
|
||||||
property int interval: PlasmaCore.Units.veryLongDuration
|
property int interval: PlasmaCore.Units.longDuration
|
||||||
|
|
||||||
readonly property int charactersOverflow: Math.ceil((txtMeter.width - parent.width + 2*rightPadding) / font.pointSize)
|
readonly property int charactersOverflow: Math.ceil((txtMeter.advanceWidth - root.width) / (txtMeter.advanceWidth / inputText.length))
|
||||||
readonly property string displayedText: inputText.substring(step, step + inputText.length - charactersOverflow)
|
readonly property string displayedText: inputText.substring(step, step + inputText.length - charactersOverflow)
|
||||||
property int step: 0
|
property int step: 0
|
||||||
|
|
||||||
TextMetrics {
|
TextMetrics {
|
||||||
id: txtMeter
|
id: txtMeter
|
||||||
font.pointSize: root.font.pointSize
|
font: root.font
|
||||||
text: inputText
|
text: inputText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,16 +38,16 @@ PlasmaComponents.Label {
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (paused) {
|
if (paused) {
|
||||||
if (step != 0) {
|
if (step != 0) {
|
||||||
|
interval = PlasmaCore.Units.veryLongDuration;
|
||||||
step = 0;
|
step = 0;
|
||||||
} else {
|
} else {
|
||||||
interval /= 3;
|
interval = root.interval;
|
||||||
paused = false;
|
paused = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
step = (step + 1) % inputText.length;
|
step = (step + 1) % inputText.length;
|
||||||
|
|
||||||
if (step === charactersOverflow) {
|
if (step === charactersOverflow) {
|
||||||
interval *= 3;
|
interval = PlasmaCore.Units.veryLongDuration * 3;
|
||||||
paused = true;
|
paused = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue