[vlc-commits] [Git][videolan/vlc][master] 8 commits: qml: fix broken EmptyLabel.qml

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Apr 7 14:21:29 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
452a2171 by Ashutosh Verma at 2025-04-07T14:05:49+00:00
qml: fix broken EmptyLabel.qml

Signed-off by: Fatih Uzunoglu <fuzun54 at outlook.com>

- - - - -
91627f5f by Ashutosh Verma at 2025-04-07T14:05:49+00:00
qml: remove StandardView from BrowseTreeDisplay.qml

Use the default loading indicator in BrowseTreeDisplay

Signed-off by: Fatih Uzunoglu <fuzun54 at outlook.com>

- - - - -
22358af9 by Ashutosh Verma at 2025-04-07T14:05:49+00:00
qml: add background in BrowseTreeDisplay EmptyLabelButton

Signed-off by: Fatih Uzunoglu <fuzun54 at outlook.com>

- - - - -
132951aa by Ashutosh Verma at 2025-04-07T14:05:49+00:00
qml: do not unload grid / list view in MainViewLoader

Stop unloading the grid / list view in MainViewLoader
when model is loading or when model is empty.

Signed-off by: Ash <ashutoshv191 at gmail.com>

- - - - -
f032fe85 by Ashutosh Verma at 2025-04-07T14:05:49+00:00
qml: use anchors.centerIn instead of anchors.fill for EmptyLabelButton

This is because EmptyLabel now has implicitWidth, implicitHeight.

Signed-off by: Ash <ashutoshv191 at gmail.com>

- - - - -
f47536e7 by Ashutosh Verma at 2025-04-07T14:05:49+00:00
qml: correct visibility of column sort row in TableViewExt

If there is a specific header, obey to its visibility
otherwise hide the column sort row if model is empty.

Signed-off by: Fatih Uzunoglu <fuzun54 at outlook.com>

- - - - -
e9ef9792 by Ashutosh Verma at 2025-04-07T14:05:49+00:00
qml: hide header when EmptyLabel is present

Hide the header when EmptyLabel is present to be displayed
when model is empty.

Signed-off by: Ash <ashutoshv191 at gmail.com>

- - - - -
9ec4c3df by Ashutosh Verma at 2025-04-07T14:05:49+00:00
qml: maintain existing behaviour in Continue Watching

Currently, the Continue Watching row is visible only when
medialibrary has some videos.

Signed-off by: Ash <ashutoshv191 at gmail.com>

- - - - -


16 changed files:

- modules/gui/qt/maininterface/qml/MainViewLoader.qml
- modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoGroupDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoPlaylistsDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoRecentVideos.qml
- modules/gui/qt/medialibrary/qml/VideoRecentVideosDisplay.qml
- modules/gui/qt/network/qml/BrowseTreeDisplay.qml
- modules/gui/qt/widgets/qml/EmptyLabel.qml
- modules/gui/qt/widgets/qml/TableViewExt.qml


Changes:

=====================================
modules/gui/qt/maininterface/qml/MainViewLoader.qml
=====================================
@@ -51,12 +51,17 @@ Widgets.StackViewExt {
     // behave like a Page
     property var pagePrefix: []
 
-    // optional, loaded when isLoading is true
-    // only loaded on initial load, when count is less then 1
-    property Component loadingComponent: null
+    // default `loadingComponent` which is instantiated as `_loadingItem`
+    // only once, i.e., when the model is loading for the first time
+    property Component loadingComponent: Component {
+        Widgets.ProgressIndicator {
+            text: ""
+        }
+    }
 
-    // NOTE: Sometimes the model has no 'loading' property.
-    readonly property bool isLoading: model.loading ?? false
+    property Item _loadingItem: null
+
+    readonly property bool isLoading: model.loading
 
     onIsLoadingChanged: {
         // Adjust the cursor. Unless the loaded item (view) sets a cursor
@@ -68,6 +73,14 @@ Widgets.StackViewExt {
         } else {
             MainCtx.unsetCursor(root)
         }
+
+        if (isLoading && !_loadingItem && loadingComponent)
+            _loadingItem = loadingComponent.createObject(this, {
+                "anchors.centerIn": root,
+                "visible": false,
+                "z": 1
+            })
+        else if (!isLoading && _loadingItem) _loadingItem.visible = false
     }
 
     readonly property int count: model.count
@@ -96,19 +109,7 @@ Widgets.StackViewExt {
 
     // NOTE: We have to use a Component here. When using a var the onCurrentComponentChanged event
     //       gets called multiple times even when the currentComponent stays the same.
-    property Component currentComponent: {
-        if (isLoading && count < 1) {
-            if (loadingComponent)
-                return loadingComponent
-            // fall through to load 'grid' or 'list' view
-        } else if (count === 0)
-            return emptyLabel
-
-        if (MainCtx.gridView)
-            return grid
-        else
-            return list
-    }
+    property Component currentComponent: MainCtx.gridView ? grid : list
 
     // Navigation
 
@@ -195,4 +196,24 @@ Widgets.StackViewExt {
         if (typeof reason !== "undefined")
             setCurrentItemFocus(reason)
     }
+
+    Timer {
+        running: isLoading && _loadingItem
+
+        interval: VLCStyle.duration_humanMoment
+
+        onTriggered: {
+            _loadingItem.visible = true
+        }
+    }
+
+    Loader {
+        anchors.centerIn: parent
+
+        z: 1
+
+        active: !count && emptyLabel && !(_loadingItem && _loadingItem.visible)
+
+        sourceComponent: emptyLabel
+    }
 }


=====================================
modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml
=====================================
@@ -29,6 +29,8 @@ MusicAlbums {
     header: Widgets.ViewHeader {
         view: root
 
+        visible: view.count > 0
+
         text: qsTr("Albums")
     }
 


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
=====================================
@@ -269,6 +269,8 @@ FocusScope {
             header: Widgets.ViewHeader {
                 view: artistList
 
+                visible: view.count > 0
+
                 leftPadding: VLCStyle.margin_normal
                 topPadding: VLCStyle.margin_xlarge
                 bottomPadding: VLCStyle.margin_small
@@ -362,9 +364,7 @@ FocusScope {
     }
 
     Widgets.EmptyLabelButton {
-        anchors.fill: parent
-        anchors.leftMargin: root.leftPadding
-        anchors.rightMargin: root.rightPadding
+        anchors.centerIn: parent
 
         visible: !artistModel.loading && (artistModel.count <= 0)
         focus: visible


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
=====================================
@@ -50,6 +50,8 @@ Widgets.PageLoader {
             header: Widgets.ViewHeader {
                 view: artistsView
 
+                visible: view.count > 0
+
                 text: qsTr("Artists")
             }
 


=====================================
modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
=====================================
@@ -46,6 +46,8 @@ Widgets.PageLoader {
             header: Widgets.ViewHeader {
                 view: genresView
 
+                visible: view.count > 0
+
                 text: qsTr("Genres")
             }
 
@@ -72,6 +74,8 @@ Widgets.PageLoader {
             header: Widgets.ViewHeader {
                 view: albumsView
 
+                visible: view.count > 0
+
                 text: qsTr("Genres - %1").arg(genreName)
             }
 


=====================================
modules/gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml
=====================================
@@ -56,6 +56,8 @@ Widgets.PageLoader {
             header: Widgets.ViewHeader {
                 view: playlistView
 
+                visible: view.count > 0
+
                 text: qsTr("Playlists")
             }
 


=====================================
modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
=====================================
@@ -65,6 +65,8 @@ FocusScope {
         header: Widgets.ViewHeader {
             view: tracklistdisplay_id
 
+            visible: view.count > 0
+
             text: qsTr("Tracks")
         }
 
@@ -85,7 +87,7 @@ FocusScope {
     }
 
     Widgets.EmptyLabelButton {
-        anchors.fill: parent
+        anchors.centerIn: parent
         visible: !tracklistdisplay_id.model.loading && (tracklistdisplay_id.model.count <= 0)
         focus: visible
         text: qsTr("No tracks found\nPlease try adding sources")


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
=====================================
@@ -211,6 +211,8 @@ FocusScope {
         header: Widgets.ViewHeader {
             view: root.playlistView
 
+            visible: view.count > 0
+
             text: root.name
         }
 
@@ -238,7 +240,7 @@ FocusScope {
     }
 
     Widgets.EmptyLabelButton {
-        anchors.fill: parent
+        anchors.centerIn: parent
 
         visible: !model.loading && (model.count <= 0)
 


=====================================
modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
=====================================
@@ -271,7 +271,9 @@ VideoAll {
         allVideosContentLeftMargin: root.currentItem?.contentLeftMargin ?? 0
         allVideosContentRightMargin: root.currentItem?.contentRightMargin ?? 0
 
-        subtitleText: (root.model && root.model.count > 0) ? qsTr("Videos") : ""
+        subtitleText: qsTr("Videos")
+
+        visible: (root.model?.count ?? 0) > 0
 
         Navigation.parentItem: root
 


=====================================
modules/gui/qt/medialibrary/qml/VideoGroupDisplay.qml
=====================================
@@ -66,6 +66,8 @@ VideoAll {
     header: Widgets.ViewHeader {
         view: root
 
+        visible: view.count > 0
+
         text: view.title
     }
 }


=====================================
modules/gui/qt/medialibrary/qml/VideoPlaylistsDisplay.qml
=====================================
@@ -56,6 +56,8 @@ Widgets.PageLoader {
             header: Widgets.ViewHeader {
                 view: playlistView
 
+                visible: view.count > 0
+
                 text: qsTr("Playlists")
             }
 


=====================================
modules/gui/qt/medialibrary/qml/VideoRecentVideos.qml
=====================================
@@ -147,8 +147,6 @@ FocusScope {
         Widgets.ViewHeader {
             id: subtitleLabel
 
-            visible: text !== ""
-
             view: root
 
             leftPadding: allVideosContentLeftMargin


=====================================
modules/gui/qt/medialibrary/qml/VideoRecentVideosDisplay.qml
=====================================
@@ -49,6 +49,8 @@ VideoAll {
     header: Widgets.ViewHeader {
         view: root
 
+        visible: view.count > 0
+
         text: qsTr("Continue Watching")
     }
 }


=====================================
modules/gui/qt/network/qml/BrowseTreeDisplay.qml
=====================================
@@ -63,8 +63,6 @@ MainViewLoader {
     grid: gridComponent
     list: tableComponent
 
-    loadingComponent: busyIndicatorComponent
-
     emptyLabel: emptyLabelComponent
 
     Navigation.cancelAction: function() {
@@ -318,116 +316,34 @@ MainViewLoader {
     Component {
         id: emptyLabelComponent
 
-        StandardView {
-            view: Widgets.EmptyLabelButton {
-                id: emptyLabel
-
-                visible: !root.isLoading
-
-                // FIXME: find better cover
-                cover: VLCStyle.noArtVideoCover
-                coverWidth : VLCStyle.dp(182, VLCStyle.scale)
-                coverHeight: VLCStyle.dp(114, VLCStyle.scale)
-
-                text: qsTr("Nothing to see here, go back.")
-
-                button.iconTxt: VLCIcons.back
-                button.text: qsTr("Back")
-                button.enabled: !History.previousEmpty
-                button.width: button.implicitWidth
-
-                function onNavigate(reason) {
-                    History.previous(reason)
-                }
-
-                Layout.fillHeight: true
-                Layout.fillWidth: true
-
-                Navigation.parentItem: root
-            }
-        }
-    }
-
-    Component {
-        id: busyIndicatorComponent
-
-        StandardView {
-            view: Item {
-                Navigation.navigable: false
-
-                visible: root.isLoading
-
-                Layout.fillHeight: true
-                Layout.fillWidth: true
+        Widgets.EmptyLabelButton {
+            id: emptyLabel
 
-                Widgets.BusyIndicatorExt {
-                    id: busyIndicator
-
-                    runningDelayed: root.isLoading
-                    anchors.centerIn: parent
-                    z: 1
-                }
+            background: Rectangle {
+                // NOTE: This is necessary because MainViewLoader may position this indicator over the shown header when height is small.
+                border.color: emptyLabel.colorContext.border
+                radius: VLCStyle.dp(6, VLCStyle.scale)
+                color: emptyLabel.colorContext.bg.primary
+                opacity: 0.8
             }
-        }
-    }
-
-    // Helper view i.e a ColumnLayout with BrowseHeader
-    component StandardView : FocusScope {
-        required property Item view
-
-        // NOTE: This is required to pass the focusReason when the current view changes in
-        //       MainViewLoader.
-        property int focusReason: (header.activeFocus) ? header.focusReason
-                                                       : view?.focusReason ?? Qt.NoFocusReason
-
-        // used by MainDisplay to transfer focus
-        function setCurrentItemFocus(reason) {
-            if (!Navigation.navigable)
-                return
 
-            if (header.Navigation.navigable)
-                Helpers.enforceFocus(header, reason)
-            else
-                Helpers.enforceFocus(view, reason)
-        }
+            // FIXME: find better cover
+            cover: VLCStyle.noArtVideoCover
+            coverWidth : VLCStyle.dp(182, VLCStyle.scale)
+            coverHeight: VLCStyle.dp(114, VLCStyle.scale)
 
-        onViewChanged: {
-            if (layout.children.length === 2)
-                layout.children.pop()
+            text: qsTr("Nothing to see here, go back.")
 
-            layout.children.push(view)
-            view.Navigation.upAction = function () {
-                // FIXME: for some reason default navigation flow doesn't work
-                // i.e setting Navigtaion.upItem doesn't fallthrough to parent's
-                // action if it's navigable is false
+            button.iconTxt: VLCIcons.back
+            button.text: qsTr("Back")
+            button.enabled: !History.previousEmpty
+            button.width: button.implicitWidth
 
-                if (header.Navigation.navigable)
-                    header.forceActiveFocus(Qt.BacktabFocusReason)
-                else
-                    return false // fallthrough default action
+            function onNavigate(reason) {
+                History.previous(reason)
             }
-        }
-
-        ColumnLayout {
-            id: layout
-
-            anchors.fill: parent
-
-            BrowseTreeHeader {
-                id: header
 
-                focus: true
-
-                leftPadding: root.headerLeftPadding
-                rightPadding: root.headerRightPadding
-
-                providerModel: root.model
-
-                Layout.fillWidth: true
-
-                Navigation.parentItem: root
-                Navigation.downItem: (view.Navigation.navigable) ? view : null
-            }
+            Navigation.parentItem: root
         }
     }
 }


=====================================
modules/gui/qt/widgets/qml/EmptyLabel.qml
=====================================
@@ -31,20 +31,28 @@ T.Control {
     readonly property int contentLeftMargin: extraMargin + VLCStyle.layout_left_margin
     readonly property int contentRightMargin: extraMargin + VLCStyle.layout_right_margin
 
+    leftPadding: contentLeftMargin
+    rightPadding: contentRightMargin
+
+    implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+                            implicitContentWidth + leftPadding + rightPadding)
+    implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+                             implicitContentHeight + topPadding + bottomPadding)
+
     // Aliases
 
     default property alias contents: column.data
 
     property alias cover: cover.source
 
-    property alias coverWidth: coverContainer.width
-    property alias coverHeight: coverContainer.height
+    property alias coverWidth: cover.width
+    property alias coverHeight: cover.height
 
     property alias text: label.text
 
     property alias column: column
 
-    spacing: VLCStyle.margin_small
+    spacing: VLCStyle.margin_normal
 
     enabled: visible
 
@@ -58,65 +66,40 @@ T.Control {
         colorSet: ColorContext.View
     }
 
-    Column {
+    contentItem: Column {
         id: column
 
-        anchors.verticalCenter: parent.verticalCenter
-        anchors.horizontalCenter: parent.horizontalCenter
-
-        width: root.width - root.contentLeftMargin - root.contentRightMargin
-
         spacing: root.spacing
 
-        Item {
-            width: parent.width
-            height: label.y + label.height
-
-            Item {
-                id: coverContainer
-
-                anchors.horizontalCenter: parent.horizontalCenter
-
-                width: VLCStyle.colWidth(1)
-                height: VLCStyle.colWidth(1)
+        ScaledImage {
+            id: cover
 
-                ScaledImage {
-                    id: cover
+            anchors.horizontalCenter: parent.horizontalCenter
 
-                    anchors.fill: parent
+            width: VLCStyle.colWidth(1)
+            height: VLCStyle.colWidth(1)
 
-                    asynchronous: true
+            fillMode: Image.PreserveAspectFit
 
-                    fillMode: Image.PreserveAspectFit
-                }
+            Widgets.DefaultShadow {
+                anchors.centerIn: parent
 
-                Widgets.DefaultShadow {
-                    anchors.centerIn: cover
-                    sourceItem: parent
-                }
+                sourceItem: parent
             }
+        }
 
-            T.Label {
-                id: label
-
-                anchors.top: coverContainer.bottom
-
-                anchors.topMargin: VLCStyle.margin_large
-
-                width: parent.width
-
-                horizontalAlignment: Text.AlignHCenter
-                verticalAlignment: Text.AlignVCenter
+        T.Label {
+            id: label
 
-                focus: false
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
 
-                wrapMode: Text.WordWrap
+            focus: false
 
-                color: theme.fg.primary
+            color: theme.fg.primary
 
-                font.pixelSize: VLCStyle.fontSize_xxlarge
-                font.weight: Font.DemiBold
-            }
+            font.pixelSize: VLCStyle.fontSize_xxlarge
+            font.weight: Font.DemiBold
         }
     }
 }


=====================================
modules/gui/qt/widgets/qml/TableViewExt.qml
=====================================
@@ -308,6 +308,7 @@ FocusScope {
                 visible: view.headerPositioning === ListView.OverlayHeader
                          && text !== ""
                          && view.contentY > (row.height - col.height - row.topPadding)
+                         && row.visible
             }
 
             Column {
@@ -336,6 +337,9 @@ FocusScope {
 
                     spacing: VLCStyle.column_spacing
 
+                    // If there is a specific header, obey to its visibility otherwise hide the header if model is empty:
+                    visible: headerLoader.item ? headerLoader.item.visible : (view.count > 0)
+
                     Repeater {
                         model: sortModel
                         Item {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2a65ba2683e514cee3fb0ca5dcb305da36b1fa77...9ec4c3dfeb154827eca1fbd18788293fb6236131

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2a65ba2683e514cee3fb0ca5dcb305da36b1fa77...9ec4c3dfeb154827eca1fbd18788293fb6236131
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