[vlc-commits] [Git][videolan/vlc][master] 2 commits: qml/KeyNavigableListView: Update differed item focus implementation
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Mon Sep 20 10:04:40 UTC 2021
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
29a904e4 by Benjamin Arnaud at 2021-09-20T09:34:29+00:00
qml/KeyNavigableListView: Update differed item focus implementation
- - - - -
f9c22eba by Benjamin Arnaud at 2021-09-20T09:34:29+00:00
qml/ServicesHomeDisplay: Add 'setCurrentItemFocus' navigation
- - - - -
3 changed files:
- modules/gui/qt/network/qml/NetworkAddressbar.qml
- modules/gui/qt/network/qml/ServicesHomeDisplay.qml
- modules/gui/qt/widgets/qml/KeyNavigableListView.qml
Changes:
=====================================
modules/gui/qt/network/qml/NetworkAddressbar.qml
=====================================
@@ -208,7 +208,7 @@ Control {
}
onSelected: {
- browse(control._menuModel[index].tree, Qt.MouseFocusReason)
+ browse(control._menuModel[index].tree, focusReason)
}
}
}
=====================================
modules/gui/qt/network/qml/ServicesHomeDisplay.qml
=====================================
@@ -59,6 +59,10 @@ Widgets.PageLoader {
isViewMultiView = currentItem.isViewMultiView === undefined || currentItem.isViewMultiView
}
+ function setCurrentItemFocus(reason) {
+ stackView.currentItem.setCurrentItemFocus(reason);
+ }
+
Component {
id: sourceRootComponent
@@ -69,9 +73,9 @@ Widgets.PageLoader {
path: [{display: deviceModel.name, tree: {}}]
onHomeButtonClicked: {
- history.push(["mc", "discover", "services"])
+ history.push(["mc", "discover", "services"]);
- stackView.currentItem.setCurrentItemFocus(reason)
+ root.setCurrentItemFocus(reason);
}
}
@@ -80,9 +84,10 @@ Widgets.PageLoader {
onBrowse: {
history.push(["mc", "discover", "services", "source_browse",
- { tree: tree, "root_name": deviceModel.name, "source_name": source_name }])
+ { tree: tree, "root_name": deviceModel.name,
+ "source_name": source_name }]);
- stackView.currentItem.setCurrentItemFocus(reason)
+ root.setCurrentItemFocus(reason);
}
NetworkDeviceModel {
@@ -115,21 +120,30 @@ Widgets.PageLoader {
}
onHomeButtonClicked: {
- history.push(["mc", "discover", "services"])
+ history.push(["mc", "discover", "services"]);
- stackView.currentItem.setCurrentItemFocus(reason)
+ root.setCurrentItemFocus(reason);
}
onBrowse: {
if (!!tree.isRoot)
- history.push(["mc", "discover", "services", "source_root", { source_name: tree.source_name }])
+ history.push(["mc", "discover", "services", "source_root",
+ { source_name: tree.source_name }]);
else
- history.push(["mc", "discover", "services", "source_browse", { tree: tree, "root": root_name }])
+ history.push(["mc", "discover", "services", "source_browse",
+ { tree: tree, "root": root_name }]);
- stackView.currentItem.setCurrentItemFocus(reason)
+ root.setCurrentItemFocus(reason);
}
}
+ onBrowse: {
+ history.push(["mc", "discover", "services", "source_browse",
+ { tree: tree, "root": root_name }]);
+
+ root.setCurrentItemFocus(reason);
+ }
+
providerModel: NetworkMediaModel {
ctx: mainctx
}
@@ -137,13 +151,6 @@ Widgets.PageLoader {
contextMenu: NetworkMediaContextMenu {
model: providerModel
}
-
- onBrowse: {
- history.push(["mc", "discover", "services", "source_browse",
- { tree: tree, "root": root_name }])
-
- stackView.currentItem.setCurrentItemFocus(reason)
- }
}
}
@@ -318,9 +325,12 @@ Widgets.PageLoader {
onItemDoubleClicked: {
if (is_dummy)
- history.push(["mc", "discover", "services", "services_manage"])
+ history.push(["mc", "discover", "services", "services_manage"]);
else
- history.push(["mc", "discover", "services", "source_root", { source_name: model.name } ])
+ history.push(["mc", "discover", "services", "source_root",
+ { source_name: model.name }]);
+
+ root.setCurrentItemFocus(Qt.MouseFocusReason);
}
onItemClicked : {
@@ -387,17 +397,25 @@ Widgets.PageLoader {
onSelectAll: selectionModel.selectAll()
onSelectionUpdated: selectionModel.updateSelection( keyModifiers, oldIndex, newIndex )
+
onActionAtIndex: {
- var itemData = sourcesFilterModel.getDataAt(index)
+ var itemData = sourcesFilterModel.getDataAt(index);
+
if (itemData.type === NetworkSourcesModel.TYPE_DUMMY)
- history.push(["mc", "discover", "services", "services_manage"])
+ history.push(["mc", "discover", "services", "services_manage"]);
else
- history.push(["mc", "discover", "services", "source_root", { source_name: itemData.name } ])
+ history.push(["mc", "discover", "services", "source_root",
+ { source_name: itemData.name }]);
+
+ root.setCurrentItemFocus(Qt.TabFocusReason);
}
Navigation.parentItem: root
+
Navigation.cancelAction: function() {
- history.previous()
+ history.previous();
+
+ root.setCurrentItemFocus(Qt.TabFocusReason);
}
NetworkSourcesModel {
=====================================
modules/gui/qt/widgets/qml/KeyNavigableListView.qml
=====================================
@@ -108,7 +108,8 @@ FocusScope {
if (_currentFocusReason === Qt.OtherFocusReason)
return;
- if (currentItem)
+ // NOTE: We make sure the view has active focus before enforcing it on the item.
+ if (view.activeFocus && currentItem)
Helpers.enforceFocus(currentItem, _currentFocusReason);
_currentFocusReason = Qt.OtherFocusReason;
@@ -118,6 +119,9 @@ FocusScope {
function setCurrentItemFocus(reason) {
if (!model || model.count === 0) {
+ // NOTE: By default we want the focus on the flickable.
+ view.forceActiveFocus(reason);
+
// NOTE: Saving the focus reason for later.
_currentFocusReason = reason;
@@ -206,6 +210,9 @@ FocusScope {
boundsBehavior: Flickable.StopAtBounds
boundsMovement :Flickable.StopAtBounds
+ // NOTE: We always want a valid 'currentIndex' by default.
+ onCountChanged: if (count && currentIndex === -1) currentIndex = 0
+
Keys.onPressed: {
var newIndex = -1
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/70a6d76c8662cc515a6eb1aad59aecd58a0084da...f9c22ebad002af6a49c5bfb8a7b4e65836037d67
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/70a6d76c8662cc515a6eb1aad59aecd58a0084da...f9c22ebad002af6a49c5bfb8a7b4e65836037d67
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list