[vlc-devel] [PATCH 20/49] qml: use navigationXXXItem navigation style

Pierre Lamot pierre at videolabs.io
Fri Oct 11 15:17:44 CEST 2019


---
 .../gui/qt/qml/mediacenter/MCMainDisplay.qml  | 49 ++++++++++---------
 .../gui/qt/qml/mediacenter/MCMusicDisplay.qml | 18 ++-----
 modules/gui/qt/qml/player/MiniPlayer.qml      |  2 +-
 3 files changed, 31 insertions(+), 38 deletions(-)

diff --git a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
index 7f1f01a171..12193ca94f 100644
--- a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
@@ -36,17 +36,32 @@ Utils.NavigableFocusScope {
 
     Component {
         id: musicComp
-        MCMusicDisplay {}
+        MCMusicDisplay {
+            navigationParent: medialibId
+            navigationUpItem: sourcesBanner
+            navigationDownItem: miniPlayer.expanded ? miniPlayer : medialibId
+            navigationCancelItem: stackViewZone
+        }
     }
 
     Component {
         id: videoComp
-        MCVideoDisplay {}
+        MCVideoDisplay {
+            navigationParent: medialibId
+            navigationUpItem: sourcesBanner
+            navigationDownItem: miniPlayer.expanded ? miniPlayer : medialibId
+            navigationCancelItem: stackViewZone
+        }
     }
 
     Component {
         id: networkComp
-        MCNetworkDisplay {}
+        MCNetworkDisplay {
+            navigationParent: medialibId
+            navigationUpItem: sourcesBanner
+            navigationDownItem: miniPlayer.expanded ? miniPlayer : medialibId
+            navigationCancelItem: stackViewZone
+        }
     }
 
     readonly property var pageModel: [
@@ -141,7 +156,7 @@ Utils.NavigableFocusScope {
                     }
 
                     navigationParent: root
-                    navigationDown: function() { stackView.focus = true }
+                    navigationDownItem: stackView
                 }
 
                 Item {
@@ -254,25 +269,13 @@ Utils.NavigableFocusScope {
                 Player.MiniPlayer {
                     id: miniPlayer
 
-                    onActionUp: stackView.focus = true
-                    onActionCancel: sourcesBanner.focus = true
-                    onActionDown: medialibId.navigationDown(index)
-                }
-            }
-
-            Connections {
-                target: stackView.currentItem
-                ignoreUnknownSignals: true
-
-                onActionUp: sourcesBanner.focus = true
-                onActionCancel: stackViewZone.focus = true
-                onActionLeft: medialibId.navigationLeft(index)
-                onActionRight: medialibId.navigationRight(index)
-                onActionDown: {
-                    if (miniPlayer.expanded)
-                        miniPlayer.focus = true
-                    else
-                        medialibId.navigationDown(index)
+                    navigationParent: medialibId
+                    navigationUpItem: stackView
+                    navigationCancelItem:sourcesBanner
+                    onExpandedChanged: {
+                        if (!expanded && miniPlayer.activeFocus)
+                            stackView.forceActiveFocus()
+                    }
                 }
             }
 
diff --git a/modules/gui/qt/qml/mediacenter/MCMusicDisplay.qml b/modules/gui/qt/qml/mediacenter/MCMusicDisplay.qml
index 67c37c5b6e..e97f116e76 100644
--- a/modules/gui/qt/qml/mediacenter/MCMusicDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MCMusicDisplay.qml
@@ -45,10 +45,10 @@ Utils.NavigableFocusScope {
         contentModel = stackView.currentItem.model
     }
 
-    Component { id: albumComp; MusicAlbumsDisplay{ } }
-    Component { id: artistComp; MusicArtistsDisplay{ } }
-    Component { id: genresComp; MusicGenresDisplay{ } }
-    Component { id: tracksComp; MusicTrackListDisplay{ } }
+    Component { id: albumComp; MusicAlbumsDisplay{ navigationParent: root } }
+    Component { id: artistComp; MusicArtistsDisplay{ navigationParent: root } }
+    Component { id: genresComp; MusicGenresDisplay{ navigationParent: root } }
+    Component { id: tracksComp; MusicTrackListDisplay{  navigationParent: root } }
 
     readonly property var pageModel: [{
             displayText: qsTr("Albums"),
@@ -100,15 +100,5 @@ Utils.NavigableFocusScope {
                     replace(pageModel[0].component)
             }
         }
-
-        Connections {
-            target: stackView.currentItem
-            ignoreUnknownSignals: true
-            onActionLeft:   root.navigationLeft(index)
-            onActionRight:  root.navigationRight(index)
-            onActionDown:   root.navigationDown(index)
-            onActionUp:     root.navigationUp(index)
-            onActionCancel: root.navigationCancel(index)
-        }
     }
 }
diff --git a/modules/gui/qt/qml/player/MiniPlayer.qml b/modules/gui/qt/qml/player/MiniPlayer.qml
index 7c5f6d1572..33fdfb2a4a 100644
--- a/modules/gui/qt/qml/player/MiniPlayer.qml
+++ b/modules/gui/qt/qml/player/MiniPlayer.qml
@@ -139,7 +139,7 @@ Utils.NavigableFocusScope {
                 Layout.preferredHeight: buttonrow.implicitHeight
 
                 navigationParent: root
-                navigationLeft: function() {  playingItemInfo.forceActiveFocus() }
+                navigationLeftItem: playingItemInfo
             }
         }
 
-- 
2.20.1



More information about the vlc-devel mailing list