Adding scrolling marquee text demo.
authorsl
Mon, 02 Jun 2014 14:07:25 +0200
changeset 25aec049087578
parent 24 783a937d3eb3
child 26 bb3f9b3c6416
Adding scrolling marquee text demo.
Manager.pro
MarqueeText.qml
TestsTab.qml
qml.qrc
     1.1 --- a/Manager.pro	Sun Jun 01 21:34:29 2014 +0200
     1.2 +++ b/Manager.pro	Mon Jun 02 14:07:25 2014 +0200
     1.3 @@ -24,4 +24,5 @@
     1.4      TestsTab.qml \
     1.5      DisplayTab.qml \
     1.6      DisplayStatusBar.qml \
     1.7 -    DisplayFrame.qml
     1.8 +    DisplayFrame.qml \
     1.9 +    MarqueeText.qml
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/MarqueeText.qml	Mon Jun 02 14:07:25 2014 +0200
     2.3 @@ -0,0 +1,44 @@
     2.4 +import QtQuick 2.2
     2.5 +
     2.6 +Item {
     2.7 +    id:marqueeText
     2.8 +    height: scrollingText.height
     2.9 +    clip: true
    2.10 +    property int tempX: 0
    2.11 +    property alias text: scrollingText.text
    2.12 +    Text {
    2.13 +        x: tempX
    2.14 +        id:scrollingText
    2.15 +    }
    2.16 +
    2.17 +    MouseArea {
    2.18 +        id:mouseArea
    2.19 +        anchors.fill: parent
    2.20 +        onClicked: {
    2.21 +            tempX = 0;
    2.22 +            timer.running = true;
    2.23 +        }
    2.24 +    }
    2.25 +
    2.26 +    Timer {
    2.27 +        id:timer
    2.28 +        interval: 33; running: false; repeat: true
    2.29 +        onTriggered:{
    2.30 +            tempX = tempX + 1
    2.31 +            scrollingText.x = -tempX;
    2.32 +
    2.33 +            if( tempX + marqueeText.width > scrollingText.width ) {
    2.34 +                timer.running = false
    2.35 +                pauseTimer.running = true
    2.36 +            }
    2.37 +        }
    2.38 +    }
    2.39 +
    2.40 +    Timer {
    2.41 +        id:pauseTimer
    2.42 +        interval: 500; running: false; repeat: false
    2.43 +        onTriggered: {
    2.44 +            scrollingText.x = 0
    2.45 +        }
    2.46 +    }
    2.47 +}
     3.1 --- a/TestsTab.qml	Sun Jun 01 21:34:29 2014 +0200
     3.2 +++ b/TestsTab.qml	Mon Jun 02 14:07:25 2014 +0200
     3.3 @@ -246,5 +246,23 @@
     3.4              onCheckedChanged: {display.frameDifferencing = checked;}
     3.5          }
     3.6  
     3.7 +        //
     3.8 +        Rectangle {
     3.9 +                border.width: 2
    3.10 +                border.color: "black"
    3.11 +                color: "lightsteelblue"
    3.12 +                anchors.horizontalCenter: parent.horizontalCenter
    3.13 +                width: 250
    3.14 +                height: text.height + 10
    3.15 +                y:100
    3.16 +                MarqueeText {
    3.17 +                    id:text
    3.18 +                    width: 200
    3.19 +                    anchors.verticalCenter: parent.verticalCenter
    3.20 +                    anchors.horizontalCenter: parent.horizontalCenter
    3.21 +                    text: "start ------ abcdefghijklmnopqrtaksdjfkdfjklsdjflksdjfklsjadfkljsad;flasjdlfjasdfjldsdfljf---- end"
    3.22 +                }
    3.23 +            }
    3.24 +
    3.25      }
    3.26  }
     4.1 --- a/qml.qrc	Sun Jun 01 21:34:29 2014 +0200
     4.2 +++ b/qml.qrc	Mon Jun 02 14:07:25 2014 +0200
     4.3 @@ -6,5 +6,6 @@
     4.4          <file>DisplayTab.qml</file>
     4.5          <file>DisplayStatusBar.qml</file>
     4.6          <file>DisplayFrame.qml</file>
     4.7 +        <file>MarqueeText.qml</file>
     4.8      </qresource>
     4.9  </RCC>