author | sl |
Mon, 02 Jun 2014 18:52:31 +0200 | |
changeset 27 | 3d3f781bf543 |
parent 26 | bb3f9b3c6416 |
child 28 | 8297924aa384 |
permissions | -rw-r--r-- |
sl@25 | 1 |
import QtQuick 2.2 |
sl@25 | 2 |
|
sl@25 | 3 |
Item { |
sl@25 | 4 |
id:marqueeText |
sl@25 | 5 |
height: scrollingText.height |
sl@25 | 6 |
clip: true |
sl@26 | 7 |
property int pixelsPerSeconds:25 |
sl@25 | 8 |
property alias text: scrollingText.text |
sl@26 | 9 |
property alias separator: separatorText.text |
sl@26 | 10 |
|
sl@25 | 11 |
Text { |
sl@25 | 12 |
id:scrollingText |
sl@25 | 13 |
} |
sl@25 | 14 |
|
sl@26 | 15 |
Text { |
sl@26 | 16 |
id:separatorText |
sl@26 | 17 |
text:" || " |
sl@26 | 18 |
x:scrollingText.x+scrollingText.width |
sl@26 | 19 |
} |
sl@26 | 20 |
|
sl@26 | 21 |
Text { |
sl@26 | 22 |
id:followingText |
sl@26 | 23 |
text:scrollingText.text |
sl@26 | 24 |
x:scrollingText.x+scrollingText.width+separatorText.width |
sl@26 | 25 |
} |
sl@26 | 26 |
|
sl@26 | 27 |
ParallelAnimation { |
sl@26 | 28 |
id: animation |
sl@26 | 29 |
loops: Animation.Infinite; |
sl@26 | 30 |
//Reset to zero and restart onStopped so that we keep looping |
sl@26 | 31 |
//onStopped: {scrollingText.x=0;running=true;} |
sl@26 | 32 |
|
sl@27 | 33 |
NumberAnimation { |
sl@26 | 34 |
target: scrollingText; |
sl@27 | 35 |
properties: "x" |
sl@26 | 36 |
//from: 0; |
sl@26 | 37 |
to: -scrollingText.width-separatorText.width; |
sl@26 | 38 |
duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds |
sl@26 | 39 |
} |
sl@26 | 40 |
|
sl@27 | 41 |
NumberAnimation { |
sl@26 | 42 |
target: separatorText; |
sl@27 | 43 |
properties: "x" |
sl@26 | 44 |
from: separatorText.x; |
sl@26 | 45 |
to: separatorText.x-scrollingText.width-separatorText.width; |
sl@26 | 46 |
duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds |
sl@26 | 47 |
} |
sl@26 | 48 |
|
sl@27 | 49 |
NumberAnimation { |
sl@26 | 50 |
target: followingText; |
sl@27 | 51 |
properties: "x" |
sl@26 | 52 |
from: followingText.x; |
sl@26 | 53 |
to: followingText.x-scrollingText.width-separatorText.width; |
sl@26 | 54 |
duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds |
sl@26 | 55 |
} |
sl@26 | 56 |
|
sl@26 | 57 |
} |
sl@26 | 58 |
|
sl@27 | 59 |
//Click to start |
sl@25 | 60 |
MouseArea { |
sl@25 | 61 |
id:mouseArea |
sl@25 | 62 |
anchors.fill: parent |
sl@25 | 63 |
onClicked: { |
sl@26 | 64 |
animation.running=true; |
sl@25 | 65 |
} |
sl@26 | 66 |
|
sl@25 | 67 |
} |
sl@25 | 68 |
} |