[vlc-commits] [Git][videolan/vlc][master] 6 commits: qml: fix double scrollbars in artists view

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Sep 2 17:43:12 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
20edad88 by Prince Gupta at 2023-09-02T17:28:42+00:00
qml: fix double scrollbars in artists view

- - - - -
d3dd2d3d by Prince Gupta at 2023-09-02T17:28:42+00:00
qml: remove unused property

- - - - -
20eafbfb by Prince Gupta at 2023-09-02T17:28:42+00:00
qml: remove redundant focus handling

focus is passed through setCurrentItemFocus, this code will only interfere with it

- - - - -
ce6ab081 by Prince Gupta at 2023-09-02T17:28:42+00:00
qml: expose originY in KeyNavigableTableView

- - - - -
aa14d4bd by Prince Gupta at 2023-09-02T17:28:42+00:00
qml: refactor position contain

- - - - -
4c15d6c6 by Prince Gupta at 2023-09-02T17:28:42+00:00
qml: make sure content is visible with key navigation in Music Artist view

- - - - -


4 changed files:

- modules/gui/qt/medialibrary/qml/MusicArtist.qml
- modules/gui/qt/util/qml/Helpers.js
- modules/gui/qt/widgets/qml/ExpandGridView.qml
- modules/gui/qt/widgets/qml/KeyNavigableTableView.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -24,6 +24,7 @@ import org.videolan.medialib 0.1
 import org.videolan.vlc 0.1
 
 import "qrc:///util/" as Util
+import "qrc:///util/Helpers.js" as Helpers
 import "qrc:///widgets/" as Widgets
 import "qrc:///main/" as MainInterface
 import "qrc:///style/"
@@ -52,11 +53,17 @@ FocusScope {
 
     property alias _currentView: view.currentItem
 
+    function navigationShowHeader(y, height) {
+        const newContentY = Helpers.flickablePositionContaining(_currentView, y, height, 0, 0)
+
+        if (newContentY !== _currentView.contentY)
+            _currentView.contentY = newContentY
+    }
+
     property Component header: FocusScope {
         id: headerFs
 
         property Item albumsListView: albumsLoader.status === Loader.Ready ? albumsLoader.item.albumsListView: null
-        property Item focusItem: albumsLoader.active ? albumsLoader.item.albumsListView : artistBanner
 
         focus: true
         height: col.height
@@ -85,6 +92,13 @@ FocusScope {
                 rightPadding: root.rightPadding
 
                 artist: root.artist
+
+                onActiveFocusChanged: {
+                    // make sure content is visible with activeFocus
+                    if (activeFocus)
+                        root.navigationShowHeader(0, height)
+                }
+
                 Navigation.parentItem: root
                 Navigation.downAction: function() {
                     if (albumsListView)
@@ -100,6 +114,13 @@ FocusScope {
 
                 active: !MainCtx.gridView
                 focus: true
+
+                onActiveFocusChanged: {
+                    // make sure content is visible with activeFocus
+                    if (activeFocus)
+                        root.navigationShowHeader(y, height)
+                }
+
                 sourceComponent: Column {
                     property alias albumsListView: albumsList
 
@@ -121,7 +142,7 @@ FocusScope {
 
                         focus: true
 
-                        height: VLCStyle.gridItem_music_height + VLCStyle.margin_normal
+                        height: VLCStyle.gridItem_music_height + topMargin + bottomMargin
                         width: root.width - root.rightPadding
 
                         leftMargin: VLCStyle.margin_xlarge
@@ -200,16 +221,6 @@ FocusScope {
     focus: true
 
     onInitialIndexChanged: resetFocus()
-    onActiveFocusChanged: {
-        if (activeFocus && albumModel.count > 0 && !albumSelectionModel.hasSelection) {
-            let initialIndex = 0
-            const albumsListView = MainCtx.gridView ? _currentView : headerItem.albumsListView
-            if (albumsListView.currentIndex !== -1)
-                initialIndex = albumsListView.currentIndex
-            albumSelectionModel.select(albumModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
-            albumsListView.currentIndex = initialIndex
-        }
-    }
 
     function setCurrentItemFocus(reason) {
         if (view.currentItem === null) {


=====================================
modules/gui/qt/util/qml/Helpers.js
=====================================
@@ -107,3 +107,33 @@ function itemsMovable(sortedItemIndexes, targetIndex) {
             (targetIndex > (sortedItemIndexes[sortedItemIndexes.length - 1] + 1) ||
              targetIndex < sortedItemIndexes[0])
 }
+
+/**
+ * calculate content y for flickable such that item with given param will be fully visible
+ * @param type:Flickable flickable
+ * @param type:real y
+ * @param type:real height
+ * @param type:real topMargin
+ * @param type:real bottomMargin
+ * @return type:real appropriate contentY for flickable
+ */
+function flickablePositionContaining(flickable, y, height, topMargin, bottomMargin) {
+    const itemTopY = flickable.originY + y
+    const itemBottomY = itemTopY + height
+
+    const viewTopY = flickable.contentY
+    const viewBottomY = viewTopY + flickable.height
+
+    let newContentY
+
+    if (itemTopY < viewTopY)
+         //item above view
+        newContentY = itemTopY - topMargin
+    else if (itemBottomY > viewBottomY)
+         //item below view
+        newContentY = itemBottomY + bottomMargin - flickable.height
+    else
+        newContentY = flickable.contentY
+
+    return newContentY
+}


=====================================
modules/gui/qt/widgets/qml/ExpandGridView.qml
=====================================
@@ -409,22 +409,10 @@ FocusScope {
             index < 0 || index >= _count)
             return
 
-        const itemTopY = getItemPos(index)[1]
-        const itemBottomY = itemTopY + rowHeight
-
-        const viewTopY = flickable.contentY
-        const viewBottomY = viewTopY + flickable.height
-
-        let newContentY
-
-        if (itemTopY < viewTopY)
-             //item above view
-            newContentY = itemTopY - topMargin
-        else if (itemBottomY > viewBottomY)
-             //item below view
-            newContentY = itemBottomY + bottomMargin - flickable.height
-        else
-            newContentY = flickable.contentY
+        const newContentY = Helpers.flickablePositionContaining(flickable,
+                                                                getItemPos(index)[1]
+                                                                , rowHeight
+                                                                , topMargin, bottomMargin)
 
         if (newContentY !== flickable.contentY)
             animateFlickableContentY(newContentY)


=====================================
modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
=====================================
@@ -103,6 +103,9 @@ FocusScope {
     property alias contentY     : view.contentY
     property alias contentHeight: view.contentHeight
 
+    property alias originX: view.originX
+    property alias originY: view.originY
+
     property alias interactive: view.interactive
 
     property alias section: view.section



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8c12f1959263a7f9638660e738d44add62429211...4c15d6c6443fe17d61dea261287f64cb40618102

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8c12f1959263a7f9638660e738d44add62429211...4c15d6c6443fe17d61dea261287f64cb40618102
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