[vlc-commits] qml: factorise navigation bindings

Pierre Lamot git at videolan.org
Fri Feb 14 12:00:12 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Feb 12 15:22:49 2020 +0100| [51683d6a6d1d5cdf928305fb9485423713ba762f] | committer: Jean-Baptiste Kempf

qml: factorise navigation bindings

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=51683d6a6d1d5cdf928305fb9485423713ba762f
---

 modules/gui/qt/medialibrary/qml/MainDisplay.qml    | 44 +++++-----------------
 modules/gui/qt/medialibrary/qml/MusicDisplay.qml   | 15 +++-----
 .../gui/qt/medialibrary/qml/MusicGenresDisplay.qml |  5 +--
 3 files changed, 17 insertions(+), 47 deletions(-)

diff --git a/modules/gui/qt/medialibrary/qml/MainDisplay.qml b/modules/gui/qt/medialibrary/qml/MainDisplay.qml
index 2524b657fb..c7903e6ec3 100644
--- a/modules/gui/qt/medialibrary/qml/MainDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MainDisplay.qml
@@ -27,7 +27,6 @@ import "qrc:///widgets/" as Widgets
 import "qrc:///util/KeyHelper.js" as KeyHelper
 import "qrc:///playlist/" as PL
 import "qrc:///player/" as Player
-import "qrc:///network/" as Network
 
 Widgets.NavigableFocusScope {
     id: root
@@ -49,6 +48,13 @@ Widgets.NavigableFocusScope {
     function loadView() {
         var found = stackView.loadView(root.pageModel, root.view, root.viewProperties)
 
+        stackView.currentItem.navigationParent = medialibId
+        stackView.currentItem.navigationUpItem = sourcesBanner
+        stackView.currentItem.navigationRightItem = playlist
+        stackView.currentItem.navigationDownItem = Qt.binding(function() {
+            return miniPlayer.expanded ? miniPlayer : medialibId
+        })
+
         sourcesBanner.subTabModel = stackView.currentItem.tabModel
         sourcesBanner.sortModel = stackView.currentItem.sortModel
         sourcesBanner.contentModel = stackView.currentItem.contentModel
@@ -77,52 +83,22 @@ Widgets.NavigableFocusScope {
             rootWindow.sendHotkey(event.key, event.modifiers);
     }
 
-    Component {
-        id: musicComp
-        MusicDisplay {
-            navigationParent: medialibId
-            navigationUpItem: sourcesBanner
-            navigationRightItem: playlist
-            navigationDownItem: miniPlayer.expanded ? miniPlayer : medialibId
-        }
-    }
-
-    Component {
-        id: videoComp
-        VideoDisplay {
-            navigationParent: medialibId
-            navigationUpItem: sourcesBanner
-            navigationRightItem: playlist
-            navigationDownItem: miniPlayer.expanded ? miniPlayer : medialibId
-        }
-    }
-
-    Component {
-        id: networkComp
-        Network.NetworkDisplay {
-            navigationParent: medialibId
-            navigationUpItem: sourcesBanner
-            navigationRightItem: playlist
-            navigationDownItem: miniPlayer.expanded ? miniPlayer : medialibId
-        }
-    }
-
     readonly property var pageModel: [
         {
             displayText: i18n.qtr("Video"),
             icon: VLCIcons.topbar_video,
             name: "video",
-            component: videoComp
+            url: "qrc:///medialibrary/VideoDisplay.qml"
         }, {
             displayText: i18n.qtr("Music"),
             icon: VLCIcons.topbar_music,
             name: "music",
-            component: musicComp
+            url: "qrc:///medialibrary/MusicDisplay.qml"
         }, {
             displayText: i18n.qtr("Network"),
             icon: VLCIcons.topbar_network,
             name: "network",
-            component: networkComp
+            url: "qrc:///network/NetworkDisplay.qml"
         }
     ]
 
diff --git a/modules/gui/qt/medialibrary/qml/MusicDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicDisplay.qml
index 3254452da2..cd1eaccf53 100644
--- a/modules/gui/qt/medialibrary/qml/MusicDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicDisplay.qml
@@ -48,6 +48,8 @@ Widgets.NavigableFocusScope {
         var found = stackView.loadView(root.pageModel, view, viewProperties)
         if (!found)
             stackView.replace(root.pageModel[0].component)
+
+        stackView.currentItem.navigationParent = root
         sortModel = stackView.currentItem.sortModel
         contentModel = stackView.currentItem.model
     }
@@ -62,27 +64,22 @@ Widgets.NavigableFocusScope {
         history.push(["mc", "music", root.pageModel[index].name])
     }
 
-    Component { id: albumComp; MusicAlbumsDisplay{ navigationParent: root } }
-    Component { id: artistComp; MusicArtistsDisplay{ navigationParent: root } }
-    Component { id: genresComp; MusicGenresDisplay{ navigationParent: root } }
-    Component { id: tracksComp; MusicTracksDisplay{  navigationParent: root } }
-
     readonly property var pageModel: [{
             displayText: i18n.qtr("Albums"),
             name: "albums",
-            component: albumComp
+            url: "qrc:///medialibrary/MusicAlbumsDisplay.qml"
         }, {
             displayText: i18n.qtr("Artists"),
             name: "artists",
-            component: artistComp
+            url: "qrc:///medialibrary/MusicArtistsDisplay.qml"
         }, {
             displayText: i18n.qtr("Genres"),
             name: "genres" ,
-            component: genresComp
+            url: "qrc:///medialibrary/MusicGenresDisplay.qml"
         }, {
             displayText: i18n.qtr("Tracks"),
             name: "tracks" ,
-            component: tracksComp
+            url: "qrc:///medialibrary/MusicTracksDisplay.qml"
         }
     ]
 
diff --git a/modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
index 05b6e930fc..945673813c 100644
--- a/modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
@@ -59,6 +59,7 @@ Widgets.NavigableFocusScope {
         var found = stackView.loadView(root.pageModel, view, viewProperties)
         if (!found)
             stackView.replace(root.pageModel[0].component)
+        stackView.currentItem.navigationParent = root
         sortModel = stackView.currentItem.sortModel
         contentModel = stackView.currentItem.model
     }
@@ -80,8 +81,6 @@ Widgets.NavigableFocusScope {
         /* List View */
         MusicGenres {
             onCurrentIndexChanged: _updateGenresAllHistory(currentIndex)
-
-            navigationParent: root
         }
     }
 
@@ -99,8 +98,6 @@ Widgets.NavigableFocusScope {
             onParentIdChanged: _updateGenresAlbumsHistory(currentIndex, parentId, genreName)
             onGenreNameChanged: _updateGenresAlbumsHistory(currentIndex, parentId, genreName)
             onCurrentIndexChanged: _updateGenresAlbumsHistory(currentIndex, parentId, genreName)
-
-            navigationParent: root
         }
     }
 



More information about the vlc-commits mailing list