[vlc-commits] [Git][videolan/vlc][master] 2 commits: qml: fix scrolling text

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Sep 19 07:45:47 UTC 2022



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
86227082 by Prince Gupta at 2022-09-19T07:21:20+00:00
qml: fix scrolling text

Text.contentWidth doesn't provide non elided text width, use
Text.implicitWidth for the required text width

fixup 206994abc03

- - - - -
15bf12a0 by Prince Gupta at 2022-09-19T07:21:20+00:00
qml: rename to root

- - - - -


1 changed file:

- modules/gui/qt/widgets/qml/ScrollingText.qml


Changes:

=====================================
modules/gui/qt/widgets/qml/ScrollingText.qml
=====================================
@@ -21,7 +21,7 @@ import QtQuick.Controls 2.4
 import "qrc:///style/"
 
 Item {
-    id: control
+    id: root
 
     readonly property alias scrolling: scrollAnimation.running
 
@@ -30,17 +30,19 @@ Item {
     property bool forceScroll: false
     property alias hoverScroll: hoverArea.enabled
 
-    readonly property bool _needsToScroll: (label.width < label.contentWidth)
+
+    readonly property real requiredTextWidth: label.implicitWidth
+    readonly property bool _needsToScroll: (label.width < requiredTextWidth)
 
     ToolTip.delay: VLCStyle.delayToolTipAppear
     ToolTip.visible: scrolling && hoverArea.containsMouse
     ToolTip.text: label.text
 
     onLabelChanged: {
-        label.width = Qt.binding(function () { return Math.min(label.implicitWidth, control.width) })
+        label.width = Qt.binding(function () { return Math.min(label.implicitWidth, root.width) })
 
         label.elide = Qt.binding(function () {
-            return control.scrolling ? Text.ElideNone : Text.ElideRight
+            return root.scrolling ? Text.ElideNone : Text.ElideRight
         })
     }
 
@@ -56,7 +58,7 @@ Item {
     SequentialAnimation {
         id: scrollAnimation
 
-        running: (control.forceScroll || hoverArea.containsMouse) && control._needsToScroll
+        running: (root.forceScroll || hoverArea.containsMouse) && root._needsToScroll
         loops: Animation.Infinite
 
         onStopped: {
@@ -71,7 +73,7 @@ Item {
             target: label
             property: "x"
             from: 0
-            to: label.width - label.contentWidth
+            to: label.width - root.requiredTextWidth
 
             maximumEasingTime: 0
             velocity: 20



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b2daa8327ce975fc0a60c072d0918e44c5de2e15...15bf12a0f3551397030bedd175bd15ad498c349a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b2daa8327ce975fc0a60c072d0918e44c5de2e15...15bf12a0f3551397030bedd175bd15ad498c349a
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list