[vlc-devel] [PATCH 19/49] qml: allow to set a default navigation target in NavigableFocusScope
Pierre Lamot
pierre at videolabs.io
Fri Oct 11 15:17:43 CEST 2019
this is the most common action, and allow node traversal like KeyNavigation
---
.../gui/qt/qml/utils/NavigableFocusScope.qml | 59 +++++++++++++++++--
1 file changed, 54 insertions(+), 5 deletions(-)
diff --git a/modules/gui/qt/qml/utils/NavigableFocusScope.qml b/modules/gui/qt/qml/utils/NavigableFocusScope.qml
index 308d3870c5..f24743becf 100644
--- a/modules/gui/qt/qml/utils/NavigableFocusScope.qml
+++ b/modules/gui/qt/qml/utils/NavigableFocusScope.qml
@@ -33,6 +33,8 @@ FocusScope {
signal actionRight( int index )
signal actionCancel( int index )
+ property bool navigable: true
+
property var navigationParent: undefined
property var navigationUp: defaultNavigationUp
property var navigationDown: defaultNavigationDown
@@ -40,8 +42,23 @@ FocusScope {
property var navigationRight: defaultNavigationRight
property var navigationCancel: defaultNavigationCancel
+ property var navigationUpItem: undefined
+ property var navigationDownItem: undefined
+ property var navigationLeftItem: undefined
+ property var navigationRightItem: undefined
+ property var navigationCancelItem: undefined
+
+
function defaultNavigationUp(index) {
- if (navigationParent) {
+ if (navigationUpItem) {
+ var item = navigationUpItem
+ while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
+ item = item.navigationUpItem
+ }
+ if (item) {
+ item.forceActiveFocus()
+ }
+ } else if (navigationParent) {
navigationParent.navigationUp(index)
} else {
actionUp(index)
@@ -49,7 +66,15 @@ FocusScope {
}
function defaultNavigationDown(index) {
- if (navigationParent) {
+ if (navigationDownItem) {
+ var item = navigationDownItem
+ while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
+ item = item.navigationDownItem
+ }
+ if (item) {
+ item.forceActiveFocus()
+ }
+ } else if (navigationParent) {
navigationParent.navigationDown(index)
} else {
actionDown(index)
@@ -57,7 +82,15 @@ FocusScope {
}
function defaultNavigationLeft(index) {
- if (navigationParent) {
+ if (navigationLeftItem) {
+ var item = navigationLeftItem
+ while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
+ item = item.navigationLeftItem
+ }
+ if (item) {
+ item.forceActiveFocus()
+ }
+ } else if (navigationParent) {
navigationParent.navigationLeft(index)
} else {
actionLeft(index)
@@ -65,7 +98,15 @@ FocusScope {
}
function defaultNavigationRight(index) {
- if (navigationParent) {
+ if (navigationRightItem) {
+ var item = navigationRightItem
+ while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
+ item = item.navigationRightItem
+ }
+ if (item) {
+ item.forceActiveFocus()
+ }
+ } else if (navigationParent) {
navigationParent.navigationRight(index)
} else {
actionRight(index)
@@ -73,7 +114,15 @@ FocusScope {
}
function defaultNavigationCancel(index) {
- if (navigationParent) {
+ if (navigationCancelItem) {
+ var item = navigationCancelItem
+ while (item && (!item.visible || !item.enabled || !(item.navigable === undefined || item.navigable))) {
+ item = item.navigationCancelItem
+ }
+ if (item) {
+ item.forceActiveFocus()
+ }
+ } else if (navigationParent) {
navigationParent.navigationCancel(index)
} else {
actionCancel(index)
--
2.20.1
More information about the vlc-devel
mailing list