[vlc-commits] qml: add a scrollable textwidget (like <marquee>)

Pierre Lamot git at videolan.org
Fri Jan 10 15:06:59 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Tue Jan  7 16:36:48 2020 +0100| [d89187657db312519cbfb8149d2b1c0303269aad] | committer: Jean-Baptiste Kempf

qml: add a scrollable textwidget (like <marquee>)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d89187657db312519cbfb8149d2b1c0303269aad
---

 modules/gui/qt/Makefile.am                   |  1 +
 modules/gui/qt/vlc.qrc                       |  1 +
 modules/gui/qt/widgets/qml/ScrollingText.qml | 72 ++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+)

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 7691353032..27442fdbe5 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -632,6 +632,7 @@ libqt_plugin_la_QML = \
 	gui/qt/widgets/qml/RoundButton.qml \
 	gui/qt/widgets/qml/RoundImage.qml \
 	gui/qt/widgets/qml/ScanProgressBar.qml \
+	gui/qt/widgets/qml/ScrollingText.qml \
 	gui/qt/widgets/qml/SearchBox.qml \
 	gui/qt/widgets/qml/SortControl.qml \
 	gui/qt/widgets/qml/SpinBoxExt.qml \
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index cf1dbc4430..afba395b70 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -208,6 +208,7 @@
         <file alias="NavigableCol.qml">widgets/qml/NavigableCol.qml</file>
         <file alias="NavigableRow.qml">widgets/qml/NavigableRow.qml</file>
         <file alias="TabButtonExt.qml">widgets/qml/TabButtonExt.qml</file>
+        <file alias="ScrollingText.qml">widgets/qml/ScrollingText.qml</file>
     </qresource>
     <qresource prefix="/util">
         <file alias="SelectableDelegateModel.qml">util/qml/SelectableDelegateModel.qml</file>
diff --git a/modules/gui/qt/widgets/qml/ScrollingText.qml b/modules/gui/qt/widgets/qml/ScrollingText.qml
new file mode 100644
index 0000000000..db01ec895e
--- /dev/null
+++ b/modules/gui/qt/widgets/qml/ScrollingText.qml
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+
+Item {
+    id: control
+
+    clip: true
+    property alias color: label.color
+    property alias font: label.font
+    property alias text: label.text
+
+    property bool scroll: false
+
+    readonly property bool _needsToScroll: (control.width < label.width)
+
+    Label {
+        id: label
+
+        SequentialAnimation {
+            id: scrollAnimation
+
+            running: control.scroll && control._needsToScroll
+            loops: Animation.Infinite
+
+            onStopped: {
+                label.x = 0
+            }
+
+            PauseAnimation {
+                duration: 1000
+            }
+
+            SmoothedAnimation {
+                target: label
+                property: "x"
+                from: 0
+                to: control.width - label.width
+
+                maximumEasingTime: 0
+                velocity: 20
+            }
+
+            PauseAnimation {
+                duration: 1000
+            }
+
+            PropertyAction {
+                target: label
+                property: "x"
+                value: 0
+            }
+        }
+    }
+}
+



More information about the vlc-commits mailing list