[vlc-commits] [Git][videolan/vlc][master] 2 commits: qml/TableColumns: Add 'subCriterias' support to 'titleDelegate'

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Feb 5 06:40:36 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
6fd00d2d by Benjamin Arnaud at 2023-02-05T06:25:40+00:00
qml/TableColumns: Add 'subCriterias' support to 'titleDelegate'

This patch adds a 'showCriterias' property to show a second label under the title label.
This label shows additional text based on the 'subCriterias' values in the rowModel. This
approach allows us to display more information when the TableView is really tight.

Co-authored-by: Pierre Lamot <pierre at videolabs.io>

- - - - -
daa4105f by Benjamin Arnaud at 2023-02-05T06:25:40+00:00
qml/VideoListDisplay: Add a '_modelSmall' property

This allows us to display more information when the view is really tight.

- - - - -


4 changed files:

- modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
- modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
- modules/gui/qt/widgets/qml/TableColumns.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
=====================================
@@ -198,6 +198,8 @@ MainInterface.MainTableView {
 
         showTitleText: false
 
+        criteriaCover: "thumbnail"
+
         //-----------------------------------------------------------------------------------------
         // TableColumns implementation
 


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
=====================================
@@ -394,6 +394,8 @@ FocusScope {
 
                 showTitleText: false
 
+                criteriaCover: "thumbnail"
+
                 //---------------------------------------------------------------------------------
                 // NOTE: When it's music we want the cover to be square
 


=====================================
modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
=====================================
@@ -40,13 +40,28 @@ MainInterface.MainTableView {
     //---------------------------------------------------------------------------------------------
     // Private
 
-    readonly property int _nbCols: VLCStyle.gridColumnsForWidth(listView_id.availableRowWidth)
+    readonly property int _nbCols: VLCStyle.gridColumnsForWidth(availableRowWidth)
 
-    //---------------------------------------------------------------------------------------------
-    // Settings
-    //---------------------------------------------------------------------------------------------
+    property var _modelSmall: [{
+        size: Math.max(2, _nbCols),
+
+        model: ({
+            criteria: mainCriteria,
+
+            subCriterias: [ "duration" ],
+
+            showSection: "title",
+
+            text: I18n.qtr("Title"),
+
+            placeHolder: VLCStyle.noArtVideoCover,
+
+            headerDelegate: tableColumns.titleHeaderDelegate,
+            colDelegate   : tableColumns.titleDelegate
+        })
+    }]
 
-    sortModel: [{
+    property var _modelMedium: [{
         size: 1,
 
         model: ({
@@ -62,7 +77,7 @@ MainInterface.MainTableView {
             colDelegate   : tableColumns.titleDelegate
         })
     }, {
-        size: Math.max(listView_id._nbCols - 2, 1),
+        size: Math.max(1, _nbCols - 2),
 
         model: ({
             criteria: mainCriteria,
@@ -85,6 +100,11 @@ MainInterface.MainTableView {
         })
     }]
 
+    // Settings
+
+    sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+                                                          : _modelMedium
+
     section.property: "title_first_symbol"
 
     rowHeight: VLCStyle.tableCoverRow_height
@@ -131,7 +151,11 @@ MainInterface.MainTableView {
     Widgets.TableColumns {
         id: tableColumns
 
-        showTitleText: false
+        showTitleText: (listView_id.sortModel === listView_id._modelSmall)
+        showCriterias: showTitleText
+
+        criteriaCover: "thumbnail"
+
         titleCover_height: VLCStyle.listAlbumCover_height
         titleCover_width: VLCStyle.listAlbumCover_width
         titleCover_radius: VLCStyle.listAlbumCover_radius


=====================================
modules/gui/qt/widgets/qml/TableColumns.qml
=====================================
@@ -29,21 +29,56 @@ import "qrc:///style/"
 Item {
     id: root
 
+    // Properties
+
     property bool showTitleText: true
+    property bool showCriterias: false
+
+    // NOTE: That's useful when we want to enforce a cover criteria for the titleDelegate.
+    property string criteriaCover: "cover"
+
     property int titleCover_width: VLCStyle.trackListAlbumCover_width
     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
         return []
     }
 
+    function getCriterias(colModel, rowModel) {
+        var criterias = colModel.subCriterias
+
+        if (criterias === undefined || criterias.length === 0)
+            return ""
+
+        var string = ""
+
+        for (var i = 0; i < criterias.length; i++) {
+            if (i) string += " • "
+
+            var criteria = rowModel[criterias[i]]
+
+            // NOTE: We can't use 'instanceof' because VLCTick is uncreatable.
+            if (criteria.toString().indexOf("VLCTick(") === 0)
+                string += criteria.formatShort()
+            else
+                string += criteria
+        }
+
+        return string
+    }
+
+    // Components
+
     property Component titleDelegate: RowLayout {
         id: titleDel
 
         property var rowModel: parent.rowModel
         property var model: parent.colModel
+
         readonly property bool containsMouse: parent.containsMouse
         readonly property bool currentlyFocused: parent.currentlyFocused
         readonly property color foregroundColor: parent.foregroundColor
@@ -67,10 +102,7 @@ Item {
                 source: {
                     var cover = null
                     if (!!titleDel.rowModel) {
-                        if (root.showTitleText)
-                            cover = titleDel.rowModel.cover
-                        else
-                            cover = titleDel.rowModel[titleDel.model.criteria]
+                        cover = titleDel.rowModel[root.criteriaCover]
                     }
                     return cover || titleDel.model.placeHolder || VLCStyle.noArtAlbumCover
                 }
@@ -98,25 +130,51 @@ Item {
             }
         }
 
-        Widgets.ScrollingText {
-            id: textRect
-
-            label: text
-            forceScroll: parent.currentlyFocused
-            clip: scrolling
-            visible: root.showTitleText
-
+        Column {
             Layout.fillHeight: true
             Layout.fillWidth: true
 
-            Widgets.ListLabel {
-                id: text
+            Layout.topMargin: VLCStyle.margin_xxsmall
+            Layout.bottomMargin: VLCStyle.margin_xxsmall
+
+            Widgets.ScrollingText {
+                id: textRect
+
+                anchors.left: parent.left
+                anchors.right: parent.right
+
+                height: (root.showCriterias) ? Math.round(parent.height / 2)
+                                             : parent.height
+
+                visible: root.showTitleText
+
+                clip: scrolling
+
+                label: text
+
+                forceScroll: titleDel.currentlyFocused
 
-                anchors.verticalCenter: parent.verticalCenter
-                text: (titleDel.rowModel && root.showTitleText)
-                      ? (titleDel.rowModel[titleDel.model.criteria] || I18n.qtr("Unknown Title"))
-                      : ""
-                color: titleDel.foregroundColor
+                Widgets.ListLabel {
+                    id: text
+
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: (titleDel.rowModel && root.showTitleText)
+                          ? (titleDel.rowModel[titleDel.model.criteria] || I18n.qtr("Unknown Title"))
+                          : ""
+                    color: titleDel.foregroundColor
+                }
+            }
+
+            Widgets.MenuCaption {
+                anchors.left: parent.left
+                anchors.right: parent.right
+
+                height: textRect.height
+
+                visible: root.showCriterias
+
+                text: (visible && titleDel.rowModel) ? root.getCriterias(titleDel.model,
+                                                                         titleDel.rowModel) : ""
             }
         }
     }
@@ -169,6 +227,8 @@ Item {
         }
     }
 
+    // Children
+
     TextMetrics {
         id: timeTextMetric
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c56a7d304c69c63b4daae4a69393e4a77ae4f86c...daa4105fb8fcdaaf40ed2961c306b6d508a03adf

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c56a7d304c69c63b4daae4a69393e4a77ae4f86c...daa4105fb8fcdaaf40ed2961c306b6d508a03adf
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