[vlc-commits] qml: cancel action goes to the first element before doing the default action

Pierre Lamot git at videolan.org
Fri Jan 10 15:06:30 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Tue Dec 17 09:51:52 2019 +0100| [9d9698f77296b6514a02ed5b62411125da684b41] | committer: Jean-Baptiste Kempf

qml: cancel action goes to the first element before doing the default action

  this allows to easily access the top menu

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

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

 .../gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml    | 13 +++++++++++++
 .../gui/qt/medialibrary/qml/MusicArtistsDisplay.qml   |  7 +++++++
 modules/gui/qt/medialibrary/qml/MusicDisplay.qml      |  2 +-
 .../gui/qt/medialibrary/qml/MusicGenresDisplay.qml    |  7 +++++++
 .../gui/qt/medialibrary/qml/MusicTracksDisplay.qml    | 19 +++++++------------
 modules/gui/qt/medialibrary/qml/VideoDisplay.qml      |  7 +++++++
 6 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml
index def0a352cb..4236071527 100644
--- a/modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml
@@ -41,6 +41,13 @@ Widgets.NavigableFocusScope {
     property var currentIndex: view.currentItem.currentIndex
 
 
+    navigationCancel: function() {
+        if (view.currentItem.currentIndex <= 0)
+            defaultNavigationCancel()
+        else
+            view.currentItem.currentIndex = 0;
+    }
+
     property Component header: Item{}
     readonly property var headerItem: view.currentItem ? view.currentItem.headerItem : undefined
 
@@ -177,6 +184,12 @@ Widgets.NavigableFocusScope {
             onSelectionUpdated: delegateModel.updateSelection( keyModifiers, oldIndex, newIndex )
 
             navigationParent: root
+            navigationCancel: function() {
+                if (listView_id.currentIndex <= 0)
+                    defaultNavigationCancel()
+                else
+                    listView_id.currentIndex = 0;
+            }
         }
     }
 
diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
index d293c7ee5f..661ba0f98c 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
@@ -125,6 +125,13 @@ Widgets.NavigableFocusScope {
 
             navigationParent: root
             navigationRightItem: view
+            navigationCancel: function() {
+                if (artistList.currentIndex <= 0)
+                    defaultNavigationCancel()
+                else
+                    artistList.currentIndex = 0;
+            }
+
         }
 
         FocusScope {
diff --git a/modules/gui/qt/medialibrary/qml/MusicDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicDisplay.qml
index 9662d04334..d83429339e 100644
--- a/modules/gui/qt/medialibrary/qml/MusicDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicDisplay.qml
@@ -62,7 +62,7 @@ Widgets.NavigableFocusScope {
     Component { id: albumComp; MusicAlbumsDisplay{ navigationParent: root } }
     Component { id: artistComp; MusicArtistsDisplay{ navigationParent: root } }
     Component { id: genresComp; MusicGenresDisplay{ navigationParent: root } }
-    Component { id: tracksComp; MusicTrackListDisplay{  navigationParent: root } }
+    Component { id: tracksComp; MusicTracksDisplay{  navigationParent: root } }
 
     readonly property var pageModel: [{
             displayText: i18n.qtr("Albums"),
diff --git a/modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
index e5cab3fe18..175d31b4bb 100644
--- a/modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
@@ -36,6 +36,13 @@ Widgets.NavigableFocusScope {
         history.push([ "mc", "music", "albums", { parentId: parent } ], History.Go)
     }
 
+    navigationCancel: function() {
+        if (view.currentItem.currentIndex <= 0)
+            defaultNavigationCancel()
+        else
+            view.currentItem.currentIndex = 0;
+    }
+
     Util.SelectableDelegateModel {
         id: delegateModel
         model: MLGenreModel {
diff --git a/modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
index 594ec77856..bcd71a8f92 100644
--- a/modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
@@ -19,21 +19,16 @@ import QtQuick 2.11
 import QtQuick.Controls 2.4
 import org.videolan.medialib 0.1
 
-import "qrc:///widgets/" as Widgets
 import "qrc:///style/"
 
-Loader {
-    id: viewLoader
-    property var model: null
 
-    sourceComponent: listViewComponent_id
+MusicTrackListDisplay {
+    id: tracklistdisplay_id
 
-    /* List View */
-    Component {
-        id: listViewComponent_id
-        MusicTrackListDisplay {
-            id: tracklistdisplay_id
-            model: viewLoader.model
-        }
+    navigationCancel: function() {
+        if (tracklistdisplay_id.currentIndex <= 0)
+            defaultNavigationCancel()
+        else
+            tracklistdisplay_id.currentIndex = 0;
     }
 }
diff --git a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
index d77aaf1229..267091d147 100644
--- a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
@@ -33,6 +33,13 @@ Widgets.NavigableFocusScope {
 
     property alias contentModel: videosDelegate.model;
 
+    navigationCancel: function() {
+        if (view.currentItem.currentIndex <= 0)
+            defaultNavigationCancel()
+        else
+            view.currentItem.currentIndex = 0;
+    }
+
     DG.ModalDialog {
         id: deleteDialog
         rootWindow: root



More information about the vlc-commits mailing list