[vlc-commits] qml: handle playlist item tooltip better

Fatih Uzunoglu git at videolan.org
Thu Oct 15 10:33:01 CEST 2020


vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Fri Oct  9 19:56:48 2020 +0300| [9d753c44307f4901794c59df477e29d7b5ae044f] | committer: Pierre Lamot

qml: handle playlist item tooltip better

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

 modules/gui/qt/playlist/qml/PLItem.qml           | 32 ++++++++++++++++++------
 modules/gui/qt/playlist/qml/PlaylistListView.qml |  5 ++++
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/modules/gui/qt/playlist/qml/PLItem.qml b/modules/gui/qt/playlist/qml/PLItem.qml
index 831174991d..8b76bacf2b 100644
--- a/modules/gui/qt/playlist/qml/PLItem.qml
+++ b/modules/gui/qt/playlist/qml/PLItem.qml
@@ -56,6 +56,31 @@ Rectangle {
 
     property bool dropVisible: false
 
+    function showTooltip(binding) {
+        plInfoTooltip.close()
+        plInfoTooltip.text = Qt.binding(function() { return (textInfo.text + '\n' + textArtist.text); })
+        plInfoTooltip.parent = textInfoColumn
+        if (plmodel.getSelection().length > 1 && binding)
+            plInfoTooltip.timeout = 2000
+        else
+            plInfoTooltip.timeout = 0
+        plInfoTooltip.visible = Qt.binding(function() { return ( (binding ? model.selected : plitem.hovered) && !overlayMenu.visible &&
+                                                                (textInfo.implicitWidth > textInfo.width || textArtist.implicitWidth > textArtist.width)); })
+
+    }
+
+    onHoveredChanged: {
+        if(hovered)
+            showTooltip(false)
+    }
+
+    readonly property bool selected : model.selected
+
+    onSelectedChanged: {
+        if(selected)
+            showTooltip(true)
+    }
+
     Connections {
         target: root
 
@@ -209,13 +234,6 @@ Rectangle {
                 Layout.fillWidth: true
                 Layout.leftMargin: VLCStyle.margin_large
 
-                ToolTip {
-                    id: textInfoExtendTooltip
-                    text: (textInfo.text + '\n' + textArtist.text)
-                    visible: (plitem.hovered || model.selected) && (textInfo.implicitWidth > textInfo.width || textArtist.implicitWidth > textArtist.width)
-                    delay: 750
-                }
-
                 Widgets.ListLabel {
                     id: textInfo
 
diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index c84d00bc2d..a0219e6271 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -450,6 +450,11 @@ Widgets.NavigableFocusScope {
                     }
                 }
 
+                ToolTip {
+                    id: plInfoTooltip
+                    delay: 750
+                }
+
                 delegate: Column {
 
                     Loader {



More information about the vlc-commits mailing list