[vlc-commits] qml: inline the 'add to medialibrary' button within the folder label

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


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Dec 19 11:58:33 2019 +0100| [7f6b9c9f721fe31b9d3aa33bbfe8d8527b24940e] | committer: Jean-Baptiste Kempf

qml: inline the 'add to medialibrary' button within the folder label

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

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

 .../gui/qt/network/qml/NetworkBrowseDisplay.qml    | 46 +++++++++++++++++-----
 1 file changed, 37 insertions(+), 9 deletions(-)

diff --git a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
index 65758d8503..70bc3e351a 100644
--- a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
+++ b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
@@ -18,6 +18,7 @@
 import QtQuick 2.11
 import QtQuick.Controls 2.4
 import QtQml.Models 2.2
+import QtQuick.Layouts 1.3
 import QtQml 2.11
 
 import org.videolan.vlc 0.1
@@ -31,14 +32,6 @@ Widgets.NavigableFocusScope {
 
     property alias tree: providerModel.tree
 
-    property var extraLocalActions: ObjectModel {
-        Widgets.TabButtonExt {
-            text:  providerModel.indexed ?  i18n.qtr("Remove from medialibrary") : i18n.qtr("Add to medialibrary")
-            visible: !providerModel.is_on_provider_list && providerModel.canBeIndexed
-            onClicked: providerModel.indexed = !providerModel.indexed
-        }
-    }
-
     NetworkMediaModel {
         id: providerModel
         ctx: mainctx
@@ -128,12 +121,29 @@ Widgets.NavigableFocusScope {
         id: gridComponent
 
         Widgets.ExpandGridView {
+            id: gridView
             model: delegateModel
             modelCount: delegateModel.items.count
 
             headerDelegate: Widgets.LabelSeparator {
-                text: providerModel.name
                 width: view.width
+                text: providerModel.name
+
+                inlineComponent: Widgets.TabButtonExt {
+                    focus: true
+                    iconTxt: providerModel.indexed ? VLCIcons.remove : VLCIcons.add
+                    text:  providerModel.indexed ?  i18n.qtr("Remove from medialibrary") : i18n.qtr("Add to medialibrary")
+                    visible: !providerModel.is_on_provider_list && providerModel.canBeIndexed
+                    onClicked: providerModel.indexed = !providerModel.indexed
+                }
+
+
+                Keys.onPressed: defaultKeyAction(event, 0)
+                navigationParent: root
+                navigationDown: function() {
+                    focus = false
+                    gridView.forceActiveFocus()
+                }
             }
 
             cellWidth: VLCStyle.network_normal + VLCStyle.margin_large
@@ -191,6 +201,7 @@ Widgets.NavigableFocusScope {
             onActionAtIndex: delegateModel.actionAtIndex(index)
 
             navigationParent: root
+            navigationUpItem: gridView.headerItem
             navigationCancel: function() {
                 history.previous(History.Go)
             }
@@ -200,6 +211,7 @@ Widgets.NavigableFocusScope {
     Component{
         id: listComponent
         Widgets.KeyNavigableListView {
+            id: listView
             height: view.height
             width: view.width
             model: delegateModel.parts.list
@@ -214,6 +226,7 @@ Widgets.NavigableFocusScope {
             onActionAtIndex: delegateModel.actionAtIndex(index)
 
             navigationParent: root
+            navigationUpItem: listView.headerItem
             navigationCancel: function() {
                 history.previous(History.Go)
             }
@@ -221,6 +234,21 @@ Widgets.NavigableFocusScope {
             header:  Widgets.LabelSeparator {
                 text: providerModel.name
                 width: view.width
+
+                inlineComponent: Widgets.TabButtonExt {
+                    focus: true
+                    iconTxt: providerModel.indexed ? VLCIcons.remove : VLCIcons.add
+                    text:  providerModel.indexed ?  i18n.qtr("Remove from medialibrary") : i18n.qtr("Add to medialibrary")
+                    visible: !providerModel.is_on_provider_list && providerModel.canBeIndexed
+                    onClicked: providerModel.indexed = !providerModel.indexed
+                }
+
+                Keys.onPressed: defaultKeyAction(event, 0)
+                navigationParent: root
+                navigationDown: function() {
+                    focus = false
+                    listView.forceActiveFocus()
+                }
             }
         }
     }



More information about the vlc-commits mailing list