diff options
Diffstat (limited to 'src/components/qt_hmi/References/Work/bananasnacks/qml/Bananas/Components/OverflowableText.qml')
-rw-r--r-- | src/components/qt_hmi/References/Work/bananasnacks/qml/Bananas/Components/OverflowableText.qml | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/components/qt_hmi/References/Work/bananasnacks/qml/Bananas/Components/OverflowableText.qml b/src/components/qt_hmi/References/Work/bananasnacks/qml/Bananas/Components/OverflowableText.qml new file mode 100644 index 0000000000..3149943613 --- /dev/null +++ b/src/components/qt_hmi/References/Work/bananasnacks/qml/Bananas/Components/OverflowableText.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 +import QtGraphicalEffects 1.0 + +Rectangle { + id: oflow_text + property alias text: text.text + property alias font: text.font + property alias fontColor: text.color + property string textAlign + color: Qt.rgba(0,0,0,0) + height: text.font.pixelSize * 1.2 + clip: true + Text { + id: text + Component.onCompleted: { + if (oflow_text.width < width) { + anchors.left = parent.left + } + else if (oflow_text.textAlign == 'center') { + anchors.horizontalCenter = parent.horizontalCenter + } + } + + NumberAnimation on anchors.leftMargin { + id: scroll_animation + to: oflow_text.width - text.width + duration: ((oflow_text.width - text.width) < 0) ? (text.width - oflow_text.width) * 15 : 0 + running: false + onStopped: { + restart_timer.start() + } + } + } + + Timer { + id: scroll_timer + running: true + interval: 3000 + onTriggered: { if (oflow_text.width < text.width) scroll_animation.start();} + } + Timer { + id: restart_timer + interval: 3000 + onTriggered: text.anchors.leftMargin = 0 + } +} |