[vlc-devel] [PATCH 07/16] qml: inline Network views delegates
Pierre Lamot
pierre at videolabs.io
Wed May 27 17:06:48 CEST 2020
---
.../qt/network/qml/NetworkBrowseDisplay.qml | 37 ++++++++++-
.../gui/qt/network/qml/NetworkHomeDisplay.qml | 52 ++++++++++++----
.../qml/NetworksSectionSelectableDM.qml | 62 +------------------
3 files changed, 77 insertions(+), 74 deletions(-)
diff --git a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
index e8f5c5049d..99f4f2f062 100644
--- a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
+++ b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
@@ -170,7 +170,7 @@ Widgets.NavigableFocusScope {
}
onContextMenuButtonClicked: {
- contextMenu.model = model
+ contextMenu.model = providerModel
contextMenu.delegateModelId = delegateModelId
contextMenu.popup()
}
@@ -194,9 +194,42 @@ Widgets.NavigableFocusScope {
id: listView
height: view.height
width: view.width
- model: delegateModelId.parts.list
+ model: providerModel
currentIndex: delegateModelId.currentIndex
+ delegate: NetworkListItem {
+ id: delegateList
+ focus: true
+
+ selected: delegateModelId.isSelected( index )
+ Connections {
+ target: delegateModelId
+ onSelectionChanged: selected = delegateModelId.isSelected(index)
+ }
+
+ onItemClicked : {
+ delegateModelId.updateSelection( modifier, delegateModelId.currentIndex, index )
+ delegateModelId.currentIndex = index
+ delegateList.forceActiveFocus()
+ }
+
+ onItemDoubleClicked: {
+ if (model.type === NetworkMediaModel.TYPE_NODE || model.type === NetworkMediaModel.TYPE_DIRECTORY)
+ history.push( ["mc", "network", { tree: model.tree } ])
+ else
+ providerModel.addAndPlay( index )
+ }
+
+ onContextMenuButtonClicked: {
+ contextMenu.model = providerModel
+ contextMenu.delegateModelId = delegateModelId
+ contextMenu.popup(menuParent)
+ }
+
+ onActionLeft: root.navigationLeft(0)
+ onActionRight: root.navigationRight(0)
+ }
+
focus: true
spacing: VLCStyle.margin_xxxsmall
diff --git a/modules/gui/qt/network/qml/NetworkHomeDisplay.qml b/modules/gui/qt/network/qml/NetworkHomeDisplay.qml
index 4008172510..1800d1cd6c 100644
--- a/modules/gui/qt/network/qml/NetworkHomeDisplay.qml
+++ b/modules/gui/qt/network/qml/NetworkHomeDisplay.qml
@@ -39,7 +39,7 @@ Widgets.NavigableFocusScope {
Label {
anchors.centerIn: parent
- visible: (machineDM.items.count === 0 && lanDM.items.count === 0 )
+ visible: (machineModel.count === 0 && lanModel.count === 0 )
font.pixelSize: VLCStyle.fontHeight_xxlarge
color: topFocusScope.activeFocus ? VLCStyle.colors.accent : VLCStyle.colors.text
text: i18n.qtr("No network shares found")
@@ -87,19 +87,19 @@ Widgets.NavigableFocusScope {
id: deviceLabel
text: i18n.qtr("Devices")
width: flickable.width
- visible: machineDM.items.count !== 0
+ visible: machineModel.count !== 0
}
Widgets.KeyNavigableListView {
id: deviceSection
focus: false
- visible: machineDM.items.count !== 0
+ visible: machineModel.count !== 0
onVisibleChanged: topFocusScope.resetFocus()
currentIndex: machineDM.currentIndex
onFocusChanged: {
- if (activeFocus && machineDM.currentIndex === -1 && machineDM.items.count > 0)
+ if (activeFocus && machineDM.currentIndex === -1 && machineModel.count > 0)
machineDM.currentIndex = 0
}
@@ -107,8 +107,23 @@ Widgets.NavigableFocusScope {
height: VLCStyle.gridItem_network_height
orientation: ListView.Horizontal
- model: machineDM.parts.grid
- modelCount: machineDM.items.count
+ model: machineModel
+ delegate: NetworkGridItem {
+ focus: true
+
+ onItemClicked : {
+ machineDM.updateSelection( modifier , machineDM.currentIndex, index)
+ machineDM.currentIndex = index
+ forceActiveFocus()
+ }
+
+ onItemDoubleClicked: {
+ if (model.type === NetworkMediaModel.TYPE_NODE || model.type === NetworkMediaModel.TYPE_DIRECTORY)
+ history.push( ["mc", "network", { tree: model.tree } ])
+ else
+ model.addAndPlay( index )
+ }
+ }
onSelectAll: machineDM.selectAll()
onSelectionUpdated: machineDM.updateSelection( keyModifiers, oldIndex, newIndex )
@@ -127,19 +142,19 @@ Widgets.NavigableFocusScope {
id: lanLabel
text: i18n.qtr("LAN")
width: flickable.width
- visible: lanDM.items.count !== 0
+ visible: lanModel.count !== 0
}
Widgets.KeyNavigableListView {
id: lanSection
- visible: lanDM.items.count !== 0
+ visible: lanModel.count !== 0
onVisibleChanged: topFocusScope.resetFocus()
focus: false
currentIndex: lanDM.currentIndex
onFocusChanged: {
- if (activeFocus && lanDM.currentIndex === -1 && lanDM.items.count > 0)
+ if (activeFocus && lanDM.currentIndex === -1 && lanModel.count > 0)
lanDM.currentIndex = 0
}
@@ -147,8 +162,23 @@ Widgets.NavigableFocusScope {
height: VLCStyle.gridItem_network_height
orientation: ListView.Horizontal
- model: lanDM.parts.grid
- modelCount: lanDM.items.count
+ model: lanModel
+ delegate: NetworkGridItem {
+ focus: true
+
+ onItemClicked : {
+ lanDM.updateSelection( modifier , lanDM.currentIndex, index)
+ lanDM.currentIndex = index
+ forceActiveFocus()
+ }
+
+ onItemDoubleClicked: {
+ if (model.type === NetworkMediaModel.TYPE_NODE || model.type === NetworkMediaModel.TYPE_DIRECTORY)
+ history.push( ["mc", "network", { tree: model.tree } ])
+ else
+ model.addAndPlay( index )
+ }
+ }
onSelectAll: lanDM.selectAll()
onSelectionUpdated: lanDM.updateSelection( keyModifiers, oldIndex, newIndex )
diff --git a/modules/gui/qt/network/qml/NetworksSectionSelectableDM.qml b/modules/gui/qt/network/qml/NetworksSectionSelectableDM.qml
index b28487f376..3b9fab306f 100644
--- a/modules/gui/qt/network/qml/NetworksSectionSelectableDM.qml
+++ b/modules/gui/qt/network/qml/NetworksSectionSelectableDM.qml
@@ -32,67 +32,7 @@ Util.SelectableDelegateModel {
property int currentIndex: -1
property string viewIndexPropertyName: "currentIndex"
- delegate: Package {
- id: element
- NetworkGridItem {
- id: delegateGrid
- focus: true
- Package.name: "grid"
-
- onItemClicked : {
- delegateModel.updateSelection( modifier , delegateModel.currentIndex, index)
- delegateModel.currentIndex = index
- delegateGrid.forceActiveFocus()
- }
-
- onItemDoubleClicked: {
- if (model.type === NetworkMediaModel.TYPE_NODE || model.type === NetworkMediaModel.TYPE_DIRECTORY)
- history.push( ["mc", "network", { tree: model.tree } ])
- else
- delegateModel.model.addAndPlay( index )
- }
-
- onContextMenuButtonClicked: {
- contextMenu.model = model
- contextMenu.delegateModel = delegateModel
- contextMenu.popup(menuParent)
- }
- }
-
- NetworkListItem {
- id: delegateList
- focus: true
- Package.name: "list"
-
- selected: delegateModel.isSelected( index )
- Connections {
- target: delegateModel
- onSelectionChanged: delegateList.selected = delegateModel.isSelected(index)
- }
-
- onItemClicked : {
- delegateModel.updateSelection( modifier, delegateModel.currentIndex, index )
- delegateModel.currentIndex = index
- delegateList.forceActiveFocus()
- }
-
- onItemDoubleClicked: {
- if (model.type === NetworkMediaModel.TYPE_NODE || model.type === NetworkMediaModel.TYPE_DIRECTORY)
- history.push( ["mc", "network", { tree: model.tree } ])
- else
- delegateModel.model.addAndPlay( index )
- }
-
- onContextMenuButtonClicked: {
- contextMenu.model = model
- contextMenu.delegateModel = delegateModel
- contextMenu.popup(menuParent)
- }
-
- onActionLeft: root.navigationLeft(0)
- onActionRight: root.navigationRight(0)
- }
-
+ delegate: Item {
}
function switchIndex() {
--
2.25.1
More information about the vlc-devel
mailing list