[vlc-commits] qml: fix initial focus not being set to the first item in NetworkHomeDisplay
Pierre Lamot
git at videolan.org
Thu Feb 13 11:06:40 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Jan 27 13:44:41 2020 +0100| [21dd7a53471336c5cb25f7a986c105daf5834c3d] | committer: Jean-Baptiste Kempf
qml: fix initial focus not being set to the first item in NetworkHomeDisplay
When the model of the Listview is being updated multiple times, the focus
remains on the last focused item, so when we prepend items to our model, this
moved the initial focused item, even if we never had the focus on the list.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=21dd7a53471336c5cb25f7a986c105daf5834c3d
---
modules/gui/qt/network/qml/NetworkHomeDisplay.qml | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/modules/gui/qt/network/qml/NetworkHomeDisplay.qml b/modules/gui/qt/network/qml/NetworkHomeDisplay.qml
index 1e6b090b2e..6e538a32d7 100644
--- a/modules/gui/qt/network/qml/NetworkHomeDisplay.qml
+++ b/modules/gui/qt/network/qml/NetworkHomeDisplay.qml
@@ -52,6 +52,10 @@ Widgets.NavigableFocusScope {
ctx: mainctx
sd_source: NetworkDeviceModel.CAT_DEVICES
}
+
+ onCurrentIndexChanged: {
+ deviceSection.currentIndex = currentIndex
+ }
}
NetworksSectionSelectableDM{
@@ -61,6 +65,10 @@ Widgets.NavigableFocusScope {
ctx: mainctx
sd_source: NetworkDeviceModel.CAT_LAN
}
+
+ onCurrentIndexChanged: {
+ lanSection.currentIndex = currentIndex
+ }
}
ScrollView {
@@ -89,6 +97,12 @@ Widgets.NavigableFocusScope {
visible: machineDM.items.count !== 0
onVisibleChanged: topFocusScope.resetFocus()
+ currentIndex: machineDM.currentIndex
+ onFocusChanged: {
+ if (activeFocus && machineDM.currentIndex === -1 && machineDM.items.count > 0)
+ machineDM.currentIndex = 0
+ }
+
width: flickable.width
height: VLCStyle.gridItem_network_height
orientation: ListView.Horizontal
@@ -123,6 +137,12 @@ Widgets.NavigableFocusScope {
onVisibleChanged: topFocusScope.resetFocus()
focus: false
+ currentIndex: lanDM.currentIndex
+ onFocusChanged: {
+ if (activeFocus && lanDM.currentIndex === -1 && lanDM.items.count > 0)
+ lanDM.currentIndex = 0
+ }
+
width: flickable.width
height: VLCStyle.gridItem_network_height
orientation: ListView.Horizontal
More information about the vlc-commits
mailing list