[vlc-commits] qml: set the focus on the first element by default in PlaylistListView

Pierre Lamot git at videolan.org
Sun Jul 28 08:44:02 CEST 2019


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Jul 26 18:44:40 2019 +0200| [1169b7436686ff7f19f8a4e2f0befe1fef085863] | committer: Jean-Baptiste Kempf

qml: set the focus on the first element by default in PlaylistListView

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

 modules/gui/qt/qml/playlist/PlaylistListView.qml | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/modules/gui/qt/qml/playlist/PlaylistListView.qml b/modules/gui/qt/qml/playlist/PlaylistListView.qml
index c60220aada..ae34af5e5b 100644
--- a/modules/gui/qt/qml/playlist/PlaylistListView.qml
+++ b/modules/gui/qt/qml/playlist/PlaylistListView.qml
@@ -73,6 +73,18 @@ Utils.NavigableFocusScope {
         property int shiftIndex: -1
         property string mode: "normal"
 
+        Connections {
+            target: root.plmodel
+            onRowsInserted: {
+                if (view.currentIndex == -1)
+                    view.currentIndex = 0
+            }
+            onModelReset: {
+                if (view.currentIndex == -1 &&  root.plmodel.count > 0)
+                    view.currentIndex = 0
+            }
+        }
+
         footer: PLItemFooter {}
 
         delegate: PLItem {



More information about the vlc-commits mailing list