From 3a04ce668f7c013b8f23be32979d1a4df1565398 Mon Sep 17 00:00:00 2001 From: waaake Date: Sat, 30 Nov 2024 20:14:13 +0530 Subject: [PATCH] [ui] GraphEditor: Search filtering fix Fixed the issue where navigation arrows on the Filtering was allowing to set an index even when the search had null as the result. Accepted signal on the Seach invokes the function rather than invoking the sigal for the button --- meshroom/ui/qml/GraphEditor/GraphEditor.qml | 47 ++++++++++++++------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/meshroom/ui/qml/GraphEditor/GraphEditor.qml b/meshroom/ui/qml/GraphEditor/GraphEditor.qml index fb534cde..3e052acd 100755 --- a/meshroom/ui/qml/GraphEditor/GraphEditor.qml +++ b/meshroom/ui/qml/GraphEditor/GraphEditor.qml @@ -1096,32 +1096,23 @@ Item { textField.onTextChanged: navigation.currentIndex = -1 onAccepted: { - nextArrow.clicked() + navigation.navigateForward() } } MaterialToolButton { text: MaterialIcons.arrow_left padding: 0 - enabled: graphSearchBar.text !== "" - onClicked: { - navigation.currentIndex-- - if (navigation.currentIndex === -1) - navigation.currentIndex = filteredNodes.count - 1 - navigation.nextItem() - } + visible: graphSearchBar.text !== "" + onClicked: navigation.navigateBackward() } MaterialToolButton { + id: nextArrow text: MaterialIcons.arrow_right padding: 0 - enabled: graphSearchBar.text !== "" - onClicked: { - navigation.currentIndex++ - if (navigation.currentIndex === filteredNodes.count) - navigation.currentIndex = 0 - navigation.nextItem() - } + visible: graphSearchBar.text !== "" + onClicked: navigation.navigateForward() } Label { @@ -1147,6 +1138,32 @@ Item { } } + function navigateForward() { + /** + * Moves the navigation index forwards and focuses on the next node as per index. + */ + if (!filteredNodes.count) + return + + navigation.currentIndex++ + if (navigation.currentIndex === filteredNodes.count) + navigation.currentIndex = 0 + navigation.nextItem() + } + + function navigateBackward() { + /** + * Moves the navigation index backwards and focuses on the previous node as per index. + */ + if (!filteredNodes.count) + return + + navigation.currentIndex-- + if (navigation.currentIndex === -1) + navigation.currentIndex = filteredNodes.count - 1 + navigation.nextItem() + } + function nextItem() { // Compute bounding box var node = nodeRepeater.itemAt(filteredNodes.itemAt(navigation.currentIndex).index_)