[vlc-commits] [Git][videolan/vlc][master] 3 commits: qml: reuse items in VideoQualityLabels

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Apr 8 17:57:38 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
21f05ba7 by Prince Gupta at 2023-04-08T17:09:44+00:00
qml: reuse items in VideoQualityLabels

improves performance when scrolling in ExpandGridView

- - - - -
5bc28f4d by Prince Gupta at 2023-04-08T17:09:44+00:00
qml: use direct function assignment for grid cover labels

- - - - -
5a52d25e by Prince Gupta at 2023-04-08T17:09:44+00:00
qml: use direct function assignment for getting title cover labels

- - - - -


5 changed files:

- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
- modules/gui/qt/widgets/qml/TableColumns.qml
- modules/gui/qt/widgets/qml/VideoQualityLabels.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -54,6 +54,11 @@ MainInterface.MainViewLoader {
 
     property alias dragItem: dragItem
 
+    // function(model) -> [strings....]
+    // used to get grid labels per model item
+    property var gridLabels: getLabel
+    property var listLabels: getLabel
+
     list: list
     grid: grid
     emptyLabel: emptylabel
@@ -179,7 +184,7 @@ MainInterface.MainViewLoader {
                           &&
                           gridView.expandIndex !== gridItem.index) ? 0.7 : 1
 
-                labels: root.onLabelGrid(model)
+               labels: root.gridLabels(model)
 
                 // FIXME: Sometimes MLBaseModel::getDataAt returns {} so we use 'isNew === true'.
                 showNewIndicator: (model.isNew === true)
@@ -267,6 +272,8 @@ MainInterface.MainViewLoader {
 
             onRightClick: root.contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
 
+            coverLabels: root.listLabels
+
             // Functions
 
             function onLabels(model) { return root.onLabelList(model); }


=====================================
modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
=====================================
@@ -55,6 +55,10 @@ VideoAll {
 
     contextMenu: Util.MLContextMenu { model: _meta ? _meta.model : null; showPlayAsAudioAction: true }
 
+    gridLabels: !!_meta ? _meta.gridLabels : root.getLabel
+
+    listLabels: !!_meta ? _meta.listLabels : root.getLabel
+
     // Functions
 
     function _updateMetaModel(groupping) {
@@ -102,9 +106,6 @@ VideoAll {
 
     function onDoubleClick(object) { _meta.onDoubleClick(object) }
 
-    function onLabelGrid(object) { return _meta.onLabelGrid(object) }
-    function onLabelList(object) { return _meta.onLabelList(object) }
-
     function isInfoExpandPanelAvailable(modelIndexData) {
         return _meta.isInfoExpandPanelAvailable(modelIndexData)
     }
@@ -126,6 +127,10 @@ VideoAll {
 
             property var model: MLVideoModel { ml: MediaLib }
 
+            property var gridLabels: root.getLabel
+
+            property var listLabels: root.getLabel
+
             function onAction(indexes) {
                 MediaLib.addAndPlay(model.getIdsForIndexes(indexes))
                 g_mainDisplay.showPlayer()
@@ -133,9 +138,6 @@ VideoAll {
 
             function onDoubleClick(object) { g_mainDisplay.play(MediaLib, object.id) }
 
-            function onLabelGrid(object) { return root.getLabel(object) }
-            function onLabelList(object) { return root.getLabel(object) }
-
             function isInfoExpandPanelAvailable(modelIndexData) { return true }
         }
     }
@@ -148,6 +150,14 @@ VideoAll {
 
             property var model: MLVideoGroupsModel { ml: MediaLib }
 
+            property var gridLabels: function (model) {
+                return root.getLabelGroup(model, I18n.qtr("%1 Videos"))
+            }
+
+            property var listLabels: function (model) {
+                return root.getLabelGroup(model, I18n.qtr("%1"))
+            }
+
             function onAction(indexes) {
                 var index = indexes[0]
 
@@ -173,14 +183,6 @@ VideoAll {
                 root.showList(object, Qt.MouseFocusReason)
             }
 
-            function onLabelGrid(object) {
-                return root.getLabelGroup(object, I18n.qtr("%1 Videos"))
-            }
-
-            function onLabelList(object) {
-                return root.getLabelGroup(object, I18n.qtr("%1"))
-            }
-
             function isInfoExpandPanelAvailable(modelIndexData) {
                 return modelIndexData.isVideo
             }
@@ -195,6 +197,14 @@ VideoAll {
 
             property var model: MLVideoFoldersModel { ml: MediaLib }
 
+            property var gridLabels: function (model) {
+                return root.getLabelGroup(model, I18n.qtr("%1 Videos"))
+            }
+
+            property var listLabels: function (model) {
+                return root.getLabelGroup(model, I18n.qtr("%1"))
+            }
+
             function onAction(indexes) {
                 var index = indexes[0]
 
@@ -205,14 +215,6 @@ VideoAll {
                 root.showList(object, Qt.MouseFocusReason)
             }
 
-            function onLabelGrid(object) {
-                return root.getLabelGroup(object, I18n.qtr("%1 Videos"))
-            }
-
-            function onLabelList(object) {
-                return root.getLabelGroup(object, I18n.qtr("%1"))
-            }
-
             function isInfoExpandPanelAvailable(modelIndexData) {
                 return false
             }


=====================================
modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
=====================================
@@ -37,6 +37,8 @@ MainInterface.MainTableView {
     // NOTE: This is useful for groups because our main criteria is 'name' instead of 'title'.
     property string mainCriteria: "title"
 
+    property alias coverLabels: tableColumns.titlecoverLabels
+
     //---------------------------------------------------------------------------------------------
     // Private
 
@@ -162,8 +164,6 @@ MainInterface.MainTableView {
         titleCover_width: VLCStyle.listAlbumCover_width
         titleCover_radius: VLCStyle.listAlbumCover_radius
 
-        function titlecoverLabels(model) {
-            return listView_id.onLabels(model);
-        }
+        titlecoverLabels: listView_id.onLabels
     }
 }


=====================================
modules/gui/qt/widgets/qml/TableColumns.qml
=====================================
@@ -41,10 +41,9 @@ Item {
     property int titleCover_height: VLCStyle.trackListAlbumCover_heigth
     property int titleCover_radius: VLCStyle.trackListAlbumCover_radius
 
-    // Functions
-
-    function titlecoverLabels(model) {
-        // implement this function to show labels in title Cover
+    // function (model) -> [string...]
+    // implement this function to show labels in title Cover
+    property var titlecoverLabels: function(model) {
         return []
     }
 


=====================================
modules/gui/qt/widgets/qml/VideoQualityLabels.qml
=====================================
@@ -22,7 +22,16 @@ import org.videolan.vlc 0.1
 import "qrc:///style/"
 
 Row {
-    property alias labels: repeater.model
+    id: root
+
+    property var labels
+
+    onLabelsChanged: {
+        // try to reuse items, texts are assigned with Binding
+        // extra items are hidden, Row should take care of them
+        if (repeater.count < labels.length)
+            repeater.model = labels.length
+    }
 
     spacing: VLCStyle.margin_xxsmall
 
@@ -42,7 +51,9 @@ Row {
             leftPadding: VLCStyle.margin_xxxsmall
             rightPadding: VLCStyle.margin_xxxsmall
 
-            text: modelData
+            visible: index < root.labels.length
+            text: index >= root.labels.length ? "" :  root.labels[index]
+
             font.pixelSize: VLCStyle.fontSize_normal
 
             color: theme.fg.primary



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/28851ad2ad422bb621d36b27161f300ccb7b7cce...5a52d25eec9dd3213bbb76349d624147ecfacbcc

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/28851ad2ad422bb621d36b27161f300ccb7b7cce...5a52d25eec9dd3213bbb76349d624147ecfacbcc
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