[vlc-devel] [PATCH 06/14] qml: allow arbitary text type in ScrollingText widget
Prince Gupta
guptaprince8832 at gmail.com
Thu Jul 2 14:23:15 CEST 2020
---
modules/gui/qt/widgets/qml/GridItem.qml | 21 ++++---
modules/gui/qt/widgets/qml/ScrollingText.qml | 61 +++++++++-----------
2 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/modules/gui/qt/widgets/qml/GridItem.qml b/modules/gui/qt/widgets/qml/GridItem.qml
index 4269cf9df2..49379b5080 100644
--- a/modules/gui/qt/widgets/qml/GridItem.qml
+++ b/modules/gui/qt/widgets/qml/GridItem.qml
@@ -29,7 +29,7 @@ Item {
id: root
property url image
- property string title: ""
+ property alias title: titleLabel.text
property string subtitle: ""
property bool selected: false
@@ -178,17 +178,22 @@ Item {
}
Widgets.ScrollingText {
- id: textTitleRect
+ id: titleTextRect
- Layout.preferredHeight: childrenRect.height
+ label: titleLabel
+ scroll: _zoomed
+
+ Layout.preferredHeight: titleLabel.contentHeight
+ Layout.topMargin: VLCStyle.margin_xxsmall
Layout.fillWidth: true
- Layout.maximumWidth: _picWidth
+ Layout.maximumWidth: pictureWidth
- text: root.title
- color: VLCStyle.colors.text
- font.pixelSize: VLCStyle.fontSize_normal
+ Widgets.MenuLabel {
+ id: titleLabel
- scroll: _zoomed || selected
+ elide: Text.ElideNone
+ width: pictureWidth
+ }
}
Text {
diff --git a/modules/gui/qt/widgets/qml/ScrollingText.qml b/modules/gui/qt/widgets/qml/ScrollingText.qml
index db01ec895e..a9889987d1 100644
--- a/modules/gui/qt/widgets/qml/ScrollingText.qml
+++ b/modules/gui/qt/widgets/qml/ScrollingText.qml
@@ -22,51 +22,46 @@ Item {
id: control
clip: true
- property alias color: label.color
- property alias font: label.font
- property alias text: label.text
+ property Text label: undefined
property bool scroll: false
- readonly property bool _needsToScroll: (control.width < label.width)
+ readonly property bool _needsToScroll: (label.width < label.contentWidth)
- Label {
- id: label
+ SequentialAnimation {
+ id: scrollAnimation
- SequentialAnimation {
- id: scrollAnimation
+ running: control.scroll && control._needsToScroll
+ loops: Animation.Infinite
- running: control.scroll && control._needsToScroll
- loops: Animation.Infinite
-
- onStopped: {
- label.x = 0
- }
+ onStopped: {
+ label.x = 0
+ }
- PauseAnimation {
- duration: 1000
- }
+ PauseAnimation {
+ duration: 1000
+ }
- SmoothedAnimation {
- target: label
- property: "x"
- from: 0
- to: control.width - label.width
+ SmoothedAnimation {
+ target: label
+ property: "x"
+ from: 0
+ to: label.width - label.contentWidth
- maximumEasingTime: 0
- velocity: 20
- }
+ maximumEasingTime: 0
+ velocity: 20
+ }
- PauseAnimation {
- duration: 1000
- }
+ PauseAnimation {
+ duration: 1000
+ }
- PropertyAction {
- target: label
- property: "x"
- value: 0
- }
+ PropertyAction {
+ target: label
+ property: "x"
+ value: 0
}
}
+
}
--
2.25.1
More information about the vlc-devel
mailing list