[vlc-devel] [PATCH 18/49] qml: allow to define extra buttons specific to the current view in the banner source
Pierre Lamot
pierre at videolabs.io
Fri Oct 11 15:17:42 CEST 2019
---
modules/gui/qt/qml/BannerSources.qml | 22 +++++++++++++++++++
.../gui/qt/qml/mediacenter/MCMainDisplay.qml | 4 ++++
2 files changed, 26 insertions(+)
diff --git a/modules/gui/qt/qml/BannerSources.qml b/modules/gui/qt/qml/BannerSources.qml
index e68c0941f7..5f8341ec94 100644
--- a/modules/gui/qt/qml/BannerSources.qml
+++ b/modules/gui/qt/qml/BannerSources.qml
@@ -45,6 +45,7 @@ Utils.NavigableFocusScope {
property alias subTabModel: localMenuGroup.model
signal toogleMenu()
+ property var extraLocalActions: undefined
property var playlistWidget: undefined
@@ -191,6 +192,10 @@ Utils.NavigableFocusScope {
}
model: ObjectModel {
+ id: localContextModel
+
+ property int countExtra: 0
+
Utils.IconToolButton {
id: list_grid_btn
size: VLCStyle.icon_normal
@@ -218,6 +223,23 @@ Utils.NavigableFocusScope {
}
}
+ Connections {
+ target: root
+ onExtraLocalActionsChanged : {
+ for (var i = 0; i < localContextModel.countExtra; i++) {
+ localContextModel.remove(localContextModel.count - localContextModel.countExtra, localContextModel.countExtra)
+ }
+
+ if (root.extraLocalActions && root.extraLocalActions instanceof ObjectModel) {
+ for (i = 0; i < root.extraLocalActions.count; i++)
+ localContextModel.append(root.extraLocalActions.get(i))
+ localContextModel.countExtra = root.extraLocalActions.count
+ } else {
+ localContextModel.countExtra = 0
+ }
+ }
+ }
+
navigationParent: root
navigationRightItem: localMenuGroup
navigationUpItem: historyGroup.navigable ? historyGroup : globalMenuGroup
diff --git a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
index d78b53f9fc..7f1f01a171 100644
--- a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
@@ -127,6 +127,7 @@ Utils.NavigableFocusScope {
subTabModel = stackView.currentItem.tabModel
sortModel = stackView.currentItem.sortModel
contentModel = stackView.currentItem.contentModel
+ extraLocalActions = stackView.currentItem.extraLocalActions
selectedIndex = index
}
@@ -136,6 +137,7 @@ Utils.NavigableFocusScope {
stackView.currentItem.loadIndex(index)
sortModel = stackView.currentItem.sortModel
contentModel = stackView.currentItem.contentModel
+ extraLocalActions = stackView.currentItem.extraLocalActions
}
navigationParent: root
@@ -186,6 +188,8 @@ Utils.NavigableFocusScope {
sourcesBanner.subTabModel = stackView.currentItem.tabModel
sourcesBanner.sortModel = stackView.currentItem.sortModel
sourcesBanner.contentModel = stackView.currentItem.contentModel
+ sourcesBanner.extraLocalActions = stackView.currentItem.extraLocalActions
+
// Restore sourcesBanner state
sourcesBanner.selectedIndex = pageModel.findIndex(function (e) {
return e.name === root.view
--
2.20.1
More information about the vlc-devel
mailing list