sl@25: import QtQuick 2.2 sl@28: import QtQuick.Controls 1.2 sl@25: sl@25: Item { sl@28: id:item sl@25: height: scrollingText.height sl@25: clip: true sl@28: antialiasing: false sl@26: property int pixelsPerSeconds:25 sl@25: property alias text: scrollingText.text sl@26: property alias separator: separatorText.text sl@26: sl@28: Label { sl@25: id:scrollingText sl@28: antialiasing: item.antialiasing sl@25: } sl@25: sl@28: Label { sl@26: id:separatorText sl@26: text:" || " sl@26: x:scrollingText.x+scrollingText.width sl@28: antialiasing: item.antialiasing sl@26: } sl@26: sl@28: Label { sl@26: id:followingText sl@26: text:scrollingText.text sl@26: x:scrollingText.x+scrollingText.width+separatorText.width sl@28: antialiasing: item.antialiasing sl@26: } sl@26: sl@26: ParallelAnimation { sl@26: id: animation sl@26: loops: Animation.Infinite; sl@26: //Reset to zero and restart onStopped so that we keep looping sl@26: //onStopped: {scrollingText.x=0;running=true;} sl@26: sl@32: property int lengthInPixels:scrollingText.width-separatorText.width-scrollingText.x; sl@32: property int durationInMs:(animation.lengthInPixels)*1000/pixelsPerSeconds; sl@32: sl@27: NumberAnimation { sl@26: target: scrollingText; sl@27: properties: "x" sl@30: from: scrollingText.x; sl@32: to: scrollingText.x-animation.lengthInPixels; sl@32: duration:animation.durationInMs sl@26: } sl@26: sl@27: NumberAnimation { sl@26: target: separatorText; sl@27: properties: "x" sl@26: from: separatorText.x; sl@32: to: separatorText.x-animation.lengthInPixels; sl@32: duration: animation.durationInMs sl@26: } sl@26: sl@27: NumberAnimation { sl@26: target: followingText; sl@27: properties: "x" sl@26: from: followingText.x; sl@32: to: followingText.x-animation.lengthInPixels; sl@32: duration: animation.durationInMs sl@26: } sl@26: sl@26: } sl@26: sl@30: //Click to start/stop sl@25: MouseArea { sl@25: id:mouseArea sl@25: anchors.fill: parent sl@32: onClicked: {animation.running=!animation.running; sl@32: /* sl@32: if (!animation.running) { sl@32: animation.start(); sl@32: return; sl@32: } sl@32: if (animation.paused) sl@32: { sl@32: console.log("resume") sl@32: animation.resume; sl@32: } sl@32: else sl@32: { sl@32: console.log("pause") sl@32: animation.pause; sl@32: }*/ sl@25: } sl@25: } sl@25: }