[vlc-commits] [Git][videolan/vlc][master] 7 commits: qml: silence warnings in albums expand delegate

Jean-Baptiste Kempf gitlab at videolan.org
Thu May 20 10:31:40 UTC 2021



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


Commits:
d8670a83 by Prince Gupta at 2021-05-20T09:55:56+00:00
qml: silence warnings in albums expand delegate

- - - - -
e392e8f0 by Prince Gupta at 2021-05-20T09:55:56+00:00
qml: fix hidden header in tableview

- - - - -
0bb61310 by Prince Gupta at 2021-05-20T09:55:56+00:00
qml/tableview: expose underlying view

- - - - -
158a30e8 by Prince Gupta at 2021-05-20T09:55:56+00:00
qml: try to show more items in expand tracks list

fixes #25597

- - - - -
5f93f0cb by Prince Gupta at 2021-05-20T09:55:56+00:00
qml: fix type of model in album expand delegate

- - - - -
f26ad96f by Prince Gupta at 2021-05-20T09:55:56+00:00
qml/gridview: fix flickering issue with expand delegates

- - - - -
a7f24ef4 by Prince Gupta at 2021-05-20T09:55:56+00:00
qml: clip album expand delegate

- - - - -


3 changed files:

- modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
- modules/gui/qt/widgets/qml/ExpandGridView.qml
- modules/gui/qt/widgets/qml/KeyNavigableTableView.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
=====================================
@@ -30,11 +30,25 @@ import "qrc:///style/"
 Widgets.NavigableFocusScope {
     id: root
 
-    property variant model: MLAlbumModel{}
-    implicitHeight: artAndControl.height + VLCStyle.margin_large + VLCStyle.margin_xxsmall
-    implicitWidth: layout.implicitWidth
+    property var model
+
     signal retract()
 
+    implicitWidth: layout.implicitWidth
+
+    implicitHeight: {
+        var verticalMargins = layout.anchors.topMargin + layout.anchors.bottomMargin
+        if (tracks.contentHeight < artAndControl.height)
+            return artAndControl.height + verticalMargins
+        return Math.min(tracks.contentHeight
+                        , tracks.listView.headerItem.height + tracks.rowHeight * 6) // show a maximum of 6 rows
+                + verticalMargins
+    }
+
+    // components should shrink with change of height, but it doesn't happen fast enough
+    // causing expand and shrink animation bit laggy, so clip the delegate to fix it
+    clip: true
+
     Rectangle {
         anchors.fill: parent
         color: VLCStyle.colors.bgAlt
@@ -134,123 +148,118 @@ Widgets.NavigableFocusScope {
                     }
 
                     navigationParent: root
-                    navigationRightItem: expand_track_id
+                    navigationRightItem: tracks
                 }
 
             }
         }
 
+        /* The list of the tracks available */
+        MusicTrackListDisplay {
+            id: tracks
 
-        ColumnLayout {
-            id: expand_infos_id
-
-            spacing: 0
+            readonly property int _nbCols: VLCStyle.gridColumnsForWidth(tracks.availableRowWidth)
 
-            Layout.fillWidth: true
-            Layout.fillHeight: true
+            property Component titleDelegate: RowLayout {
+                property var rowModel: parent.rowModel
 
-            RowLayout {
-                Layout.fillWidth: true
-                Layout.preferredHeight: expand_infos_title_id.implicitHeight
+                anchors.fill: parent
 
-                /* The title of the albums */
-                Widgets.SubtitleLabel {
-                    id: expand_infos_title_id
+                Widgets.ListLabel {
+                    text: !!rowModel && !!rowModel.track_number ? rowModel.track_number : ""
+                    color: foregroundColor
+                    font.weight: Font.Normal
 
-                    text: model.title || i18n.qtr("Unknown title")
-
-                    Layout.fillWidth: true
-                    Layout.preferredHeight: implicitHeight
+                    Layout.fillHeight: true
+                    Layout.leftMargin: VLCStyle.margin_xxsmall
+                    Layout.preferredWidth: VLCStyle.margin_large
                 }
 
-                Widgets.IconLabel {
-                    text: VLCIcons.close
+                Widgets.ListLabel {
+                    text: !!rowModel && !!rowModel.title ? rowModel.title : ""
+                    color: foregroundColor
 
-                    MouseArea {
-                        anchors.fill: parent
-                        onClicked: root.retract()
-                    }
+                    Layout.fillHeight: true
+                    Layout.fillWidth: true
                 }
             }
 
-            Widgets.CaptionLabel {
-                id: expand_infos_subtitle_id
+            property Component titleHeaderDelegate: Row {
 
-                text: i18n.qtr("%1 - %2 - %3")
-                    .arg(model.main_artist || i18n.qtr("Unknown artist"))
-                    .arg(model.release_year || "")
-                    .arg(Helpers.msToString(model.duration) || "")
+                Widgets.CaptionLabel {
+                    text: "#"
+                    width: VLCStyle.margin_large
+                }
 
-                Layout.fillWidth: true
-                Layout.preferredHeight: implicitHeight
+                Widgets.CaptionLabel {
+                    text: i18n.qtr("Title")
+                }
             }
 
-            /* The list of the tracks available */
-            MusicTrackListDisplay {
-                id: expand_track_id
-
-                readonly property int _nbCols: VLCStyle.gridColumnsForWidth(expand_track_id.availableRowWidth)
+            header: Column {
+                width: tracks.width
+                height: implicitHeight
+                bottomPadding: VLCStyle.margin_large
 
-                property Component titleDelegate: RowLayout {
-                    property var rowModel: parent.rowModel
+                RowLayout {
+                    width: parent.width
 
-                    anchors.fill: parent
+                    /* The title of the albums */
+                    Widgets.SubtitleLabel {
+                        id: expand_infos_title_id
 
-                    Widgets.ListLabel {
-                        text: rowModel ? rowModel.track_number : ""
-                        color: foregroundColor
-                        font.weight: Font.Normal
+                        text: model.title || i18n.qtr("Unknown title")
 
-                        Layout.fillHeight: true
-                        Layout.preferredWidth: VLCStyle.margin_large
+                        Layout.fillWidth: true
                     }
 
-                    Widgets.ListLabel {
-                        text: rowModel ? rowModel.title : ""
-                        color: foregroundColor
+                    Widgets.IconLabel {
+                        text: VLCIcons.close
 
-                        Layout.fillHeight: true
-                        Layout.fillWidth: true
+                        Layout.rightMargin: VLCStyle.margin_small
+
+                        MouseArea {
+                            anchors.fill: parent
+                            onClicked: root.retract()
+                        }
                     }
                 }
 
-                property Component titleHeaderDelegate: Row {
-
-                    Widgets.CaptionLabel {
-                        text: "#"
-                        width: VLCStyle.margin_large
-                    }
+                Widgets.CaptionLabel {
+                    id: expand_infos_subtitle_id
 
-                    Widgets.CaptionLabel {
-                        text: i18n.qtr("Title")
-                    }
+                    width: parent.width
+                    text: i18n.qtr("%1 - %2 - %3")
+                        .arg(model.main_artist || i18n.qtr("Unknown artist"))
+                        .arg(model.release_year || "")
+                        .arg(Helpers.msToString(model.duration) || "")
                 }
+            }
 
-                section.property: ""
+            headerPositioning: ListView.InlineHeader
+            section.property: ""
 
-                Layout.fillWidth: true
-                Layout.fillHeight: true
-                Layout.topMargin: VLCStyle.margin_large
+            Layout.fillWidth: true
+            Layout.fillHeight: true
 
-                rowHeight: VLCStyle.tableRow_height
-                headerColor: VLCStyle.colors.bgAlt
+            rowHeight: VLCStyle.tableRow_height
+            headerColor: VLCStyle.colors.bgAlt
 
-                parentId : root.model.id
-                onParentIdChanged: {
-                    currentIndex = 0
-                }
+            parentId: root.model.id
+            onParentIdChanged: {
+                currentIndex = 0
+            }
 
-                sortModel: [
-                    { isPrimary: true, criteria: "title", width: VLCStyle.colWidth(Math.max(expand_track_id._nbCols - 1, 1)), visible: true, text: i18n.qtr("Title"), showSection: "", colDelegate: titleDelegate, headerDelegate: titleHeaderDelegate },
-                    { criteria: "duration",               width: VLCStyle.colWidth(1), visible: true, showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
-                ]
+            sortModel: [
+                { isPrimary: true, criteria: "title", width: VLCStyle.colWidth(Math.max(tracks._nbCols - 1, 1)), visible: true, text: i18n.qtr("Title"), showSection: "", colDelegate: titleDelegate, headerDelegate: titleHeaderDelegate },
+                { criteria: "duration",               width: VLCStyle.colWidth(1), visible: true, showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
+            ]
 
-                navigationParent: root
-                navigationLeftItem: actionButtons
+            navigationParent: root
+            navigationLeftItem: actionButtons
 
-                Widgets.TableColumns {
-                    id: tableColumns
-                }
+            Widgets.TableColumns {
+                id: tableColumns
             }
         }
     }


=====================================
modules/gui/qt/widgets/qml/ExpandGridView.qml
=====================================
@@ -443,7 +443,13 @@ NavigableFocusScope {
             sourceComponent: expandDelegate
             active: root.expandIndex !== -1
             focus: active
-            onLoaded: item.height = 0
+
+            onLoaded: {
+                item.height = 0
+
+                // only make loader visible after setting initial y pos from layout() as to not get flickering
+                expandItemLoader.visible = false
+            }
         }
 
 
@@ -551,6 +557,8 @@ NavigableFocusScope {
             if (root.expandIndex !== -1) {
                 var expandItemPos = root.getItemPos(expandItemGridId)
                 expandItem.y = expandItemPos[1]
+                if (!expandItemLoader.visible)
+                    expandItemLoader.visible = true
             }
 
             // Place the delegates after the expandItem


=====================================
modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
=====================================
@@ -89,6 +89,7 @@ NavigableFocusScope {
     property Item dragItem
 
     property alias listScrollBar: view.listScrollBar
+    property alias listView: view.listView
 
     property alias displayMarginEnd: view.displayMarginEnd
 
@@ -98,6 +99,10 @@ NavigableFocusScope {
         view.positionViewAtIndex(index, mode)
     }
 
+    function positionViewAtBeginning() {
+        view.listView.positionViewAtBeginning()
+    }
+
     Timer {
         id: availableRowWidthUpdater
 
@@ -158,6 +163,12 @@ NavigableFocusScope {
             visible: view.modelCount > 0
             z: 3
 
+            // with inline header positioning and for `root.header` which changes it's height after loading,
+            // in such cases after `root.header` completes, the ListView will try to maintain the relative contentY,
+            // and hide the completed `root.header`, try to show the `root.header` in such cases by manually
+            // positiing view at beginning
+            onHeightChanged: if (root.contentY < 0) root.positionViewAtBeginning()
+
             Widgets.ListLabel {
                 x: contentX - VLCStyle.table_section_width
                 y: row.y



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/79b0d4b284e1eda210f8753d9d88c8c2dafd9e4d...a7f24ef49f462442749f14e19388ffb3d6d03bd5

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/79b0d4b284e1eda210f8753d9d88c8c2dafd9e4d...a7f24ef49f462442749f14e19388ffb3d6d03bd5
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list