[vlc-commits] [Git][videolan/vlc][master] qml: cleanup video recent view

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Wed Mar 9 07:03:50 UTC 2022



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


Commits:
d8f6e988 by Prince Gupta at 2022-03-08T23:11:04+00:00
qml: cleanup video recent view

also fixes Video caption not visible when recent model is empty

- - - - -


3 changed files:

- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -140,10 +140,8 @@ FocusScope {
 
     function _onNavigationUp() {
         // NOTE: We are calling the header focus function when we have one.
-        if (headerItem && headerItem.visible
-            &&
-            (typeof headerItem.setCurrentItemFocus === "function"))
-            headerItem.setCurrentItemFocus(Qt.TabFocusReason)
+        if (headerItem && headerItem.focus)
+            headerItem.forceActiveFocus(Qt.TabFocusReason)
         else
             Navigation.defaultNavigationUp()
     }
@@ -312,10 +310,11 @@ FocusScope {
     Component {
         id: list
 
-        VideoListDisplay
-        {
+        VideoListDisplay {
             id: listView
 
+            readonly property real contentMargin: VLCStyle.margin_normal
+
             // Settings
 
             model: root.model


=====================================
modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
=====================================
@@ -83,8 +83,8 @@ VideoAll {
     // VideoAll reimplementation
 
     function setCurrentItemFocus(reason) {
-        if (modelRecent.count)
-            headerItem.setCurrentItemFocus(reason)
+        if (headerItem && headerItem.focus)
+            headerItem.forceActiveFocus(reason)
         else
             _currentView.setCurrentItemFocus(reason)
     }
@@ -187,78 +187,17 @@ VideoAll {
         }
     }
 
-    // Children
-
-    MLRecentsVideoModel {
-        id: modelRecent
-
-        ml: MediaLib
-    }
-
-    header: Column {
-        property Item focusItem: (loader.status === Loader.Ready) ? loader.item.focusItem
-                                                                  : null
-
-        property alias loader: loader
-
+    header: VideoDisplayRecentVideos {
         width: root.width
 
-        topPadding: VLCStyle.margin_normal
-        bottomPadding: VLCStyle.margin_normal
-
-        // NOTE: We want the header to be visible when we have at least one media visible.
-        //       Otherwise it overlaps the default caption.
-        visible: (root.model.count && modelRecent.count)
-
-        function setCurrentItemFocus(reason) {
-            var item = loader.item;
-
-            if (item)
-                item.setCurrentItemFocus(reason);
-        }
-
-        Loader {
-            id: loader
-
-            anchors.left : parent.left
-            anchors.right: parent.right
+        // NOTE: We want grid items to be visible on the sides.
+        leftPadding: root.contentMargin
 
-            anchors.margins: root.contentMargin
+        Navigation.parentItem: root
 
-            height: (status === Loader.Ready) ? item.implicitHeight : 0
-
-            active: (modelRecent.count)
-
-            visible: active
-
-            sourceComponent: VideoDisplayRecentVideos {
-                id: component
-
-                width: parent.width
-
-                // NOTE: We want grid items to be visible on the sides.
-                displayMargins: root.contentMargin
-
-                model: modelRecent
-
-                focus: true
-
-                Navigation.parentItem: root
-
-                Navigation.downAction: function() {
-                    _currentView.setCurrentItemFocus(Qt.TabFocusReason);
-                }
-            }
+        Navigation.downAction: function() {
+            _currentView.setCurrentItemFocus(Qt.TabFocusReason);
         }
 
-        Widgets.SubtitleLabel {
-            anchors.left: loader.left
-            anchors.right: loader.right
-
-            // NOTE: We want this to be properly aligned with the grid items.
-            anchors.leftMargin: VLCStyle.margin_normal
-
-            text: I18n.qtr("Videos")
-        }
     }
 }


=====================================
modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
=====================================
@@ -30,35 +30,17 @@ import "qrc:///style/"
 FocusScope {
     id: root
 
-    // Properties
-
-    property Item focusItem: listView
-
-    property alias currentIndex: listView.currentIndex
-
-    property alias model: listView.model
-
-    // Properties
-
-    property int displayMargins: 0
+    property alias leftPadding: recentVideosColumn.leftPadding
+    property alias rightPadding: recentVideosColumn.rightPadding
 
     // Settings
 
     implicitHeight: recentVideosColumn.height
 
-    // Events
-
-    onFocusChanged: {
-        if (activeFocus && root.currentIndex === -1 && root.model.count > 0)
-            root.currentIndex = 0
-    }
+    focus: listView.count > 0
 
     // Functions
 
-    function setCurrentItemFocus(reason) {
-        listView.setCurrentItemFocus(reason)
-    }
-
     function _actionAtIndex(index) {
         g_mainDisplay.showPlayer()
         MediaLib.addAndPlay( model.getIdForIndexes(index), [":restore-playback-pos=2"] )
@@ -69,7 +51,7 @@ FocusScope {
     VideoContextMenu {
         id: contextMenu
 
-        model: root.model
+        model: listView.model
     }
 
     Column {
@@ -79,22 +61,20 @@ FocusScope {
 
         spacing: VLCStyle.margin_xsmall
 
-        Widgets.SubtitleLabel {
-            id: continueWatchingLabel
+        topPadding: VLCStyle.margin_normal
 
-            anchors.left: parent.left
-            anchors.right: parent.right
-
-            // NOTE: We want this to be properly aligned with the grid items.
-            anchors.leftMargin: VLCStyle.margin_normal
+        bottomPadding: VLCStyle.margin_normal
 
+        Widgets.SubtitleLabel {
             text: I18n.qtr("Continue Watching")
+
+            visible: listView.visible
         }
 
         Widgets.KeyNavigableListView {
             id: listView
 
-            width: parent.width
+            width: root.width - root.leftPadding - root.rightPadding
 
             implicitHeight: VLCStyle.gridItem_video_height + VLCStyle.gridItemSelectedBorder
                             +
@@ -103,8 +83,8 @@ FocusScope {
             spacing: VLCStyle.column_margin_width
 
             // NOTE: Sometimes, we want items to be visible on the sides.
-            displayMarginBeginning: root.displayMargins
-            displayMarginEnd: root.displayMargins
+            displayMarginBeginning: root.leftPadding
+            displayMarginEnd: root.leftPadding
 
             // NOTE: We want navigation buttons to be centered on the item cover.
             buttonMargin: VLCStyle.margin_xsmall + VLCStyle.gridCover_video_height / 2 - buttonLeft.height / 2
@@ -117,6 +97,12 @@ FocusScope {
 
             Navigation.parentItem: root
 
+            visible: listView.count > 0
+
+            model: MLRecentsVideoModel {
+                ml: MediaLib
+            }
+
             header: Item {
                 width: VLCStyle.margin_normal
             }
@@ -192,5 +178,9 @@ FocusScope {
                 coverHeight: VLCStyle.gridCover_video_height
             }
         }
+
+        Widgets.SubtitleLabel {
+            text: I18n.qtr("Videos")
+        }
     }
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/d8f6e988339d75f3d713a4c484efcd432effbac6

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