[vlc-devel] [PATCH 09/12] qml/VideoAll: Add support for different models qml/VideoGridItem: Remove the static 'onItemDoubleClicked' behavior

Benjamin Arnaud benjamin.arnaud at videolabs.io
Wed Apr 14 08:05:56 UTC 2021


---
 modules/gui/qt/medialibrary/qml/VideoAll.qml  | 41 ++++++++++---------
 .../gui/qt/medialibrary/qml/VideoGridItem.qml |  6 ---
 2 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/modules/gui/qt/medialibrary/qml/VideoAll.qml b/modules/gui/qt/medialibrary/qml/VideoAll.qml
index 56e7ff9334..01b3388cf5 100644
--- a/modules/gui/qt/medialibrary/qml/VideoAll.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoAll.qml
@@ -44,6 +44,8 @@ Widgets.NavigableFocusScope {
 
     property int initialIndex: 0
 
+    property var model: MLVideoModel { ml: medialib }
+
     property var sortModel: [
         { text: i18n.qtr("Alphabetic"), criteria: "title"          },
         { text: i18n.qtr("Duration"),   criteria: "duration" }
@@ -53,11 +55,6 @@ Widgets.NavigableFocusScope {
     // Aliases
     //---------------------------------------------------------------------------------------------
 
-    // NOTE: This is used to determine which media(s) shall be displayed.
-    property alias parentId: model.parentId
-
-    property alias model: model
-
     property alias currentItem: view.currentItem
 
     //---------------------------------------------------------------------------------------------
@@ -99,6 +96,16 @@ Widgets.NavigableFocusScope {
         }
     }
 
+    Connections {
+        target: model
+
+        onCountChanged: {
+            if (count === 0 || modelSelect.hasSelection) return;
+
+            resetFocus();
+        }
+    }
+
     //---------------------------------------------------------------------------------------------
     // Functions
     //---------------------------------------------------------------------------------------------
@@ -122,7 +129,7 @@ Widgets.NavigableFocusScope {
     //---------------------------------------------------------------------------------------------
     // Private
 
-    function _actionAtIndex(index) {
+    function _actionAtIndex() {
         g_mainDisplay.showPlayer();
 
         medialib.addAndPlay(model.getIdsForIndexes(modelSelect.selectedIndexes));
@@ -132,18 +139,6 @@ Widgets.NavigableFocusScope {
     // Childs
     //---------------------------------------------------------------------------------------------
 
-    MLVideoModel {
-        id: model
-
-        ml: medialib
-
-        onCountChanged: {
-            if (count === 0 || modelSelect.hasSelection) return;
-
-            resetFocus();
-        }
-    }
-
     Widgets.StackViewExt {
         id: view
 
@@ -255,6 +250,12 @@ Widgets.NavigableFocusScope {
 
                 onItemClicked: gridView.leftClickOnItem(modifier, index)
 
+                onItemDoubleClicked: {
+                    g_mainDisplay.showPlayer();
+
+                    medialib.addAndPlay(model.id);
+                }
+
                 onContextMenuButtonClicked: {
                     gridView.rightClickOnItem(index);
 
@@ -284,7 +285,7 @@ Widgets.NavigableFocusScope {
 
             onSelectionUpdated: modelSelect.updateSelection(keyModifiers, oldIndex, newIndex)
 
-            onActionAtIndex: _actionAtIndex(index)
+            onActionAtIndex: _actionAtIndex()
 
             //-------------------------------------------------------------------------------------
             // Connections
@@ -325,6 +326,8 @@ Widgets.NavigableFocusScope {
             //-------------------------------------------------------------------------------------
             // Events
 
+            onActionForSelection: medialib.addAndPlay(model.getIdsForIndexes(selection))
+
             onContextMenuButtonClicked: contextMenu.popup(modelSelect.selectedIndexes,
                                                           menuParent.mapToGlobal(0,0))
 
diff --git a/modules/gui/qt/medialibrary/qml/VideoGridItem.qml b/modules/gui/qt/medialibrary/qml/VideoGridItem.qml
index 86a0e59181..e090035814 100644
--- a/modules/gui/qt/medialibrary/qml/VideoGridItem.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoGridItem.qml
@@ -40,12 +40,6 @@ Widgets.GridItem {
     playCoverBorder.width: VLCStyle.gridCover_video_border
     titleMargin: VLCStyle.margin_xxsmall
     showNewIndicator: true
-    onItemDoubleClicked: {
-        if ( model.id !== undefined ) {
-            g_mainDisplay.showPlayer()
-            medialib.addAndPlay( model.id )
-        }
-    }
     onPlayClicked: {
         if ( model.id !== undefined ) {
             g_mainDisplay.showPlayer()
-- 
2.25.1



More information about the vlc-devel mailing list