Skip to content

Commit d07e56a

Browse files
committed
[ImageGallery] Correctly set the selected index of the gallery model
The selected index was only being updated when the user clicked on an image delegate in the gallery, but never when the `selectedViewId` was changed from an external source, such as the Sequence Player or the 3D Viewer. `currentIndex` was correctly updated (meaning the navigation index of the gallery was indeed correct, i.e. including the selected view) but `selectedIndex` itself was never updated, so the highlight remained on the previously selected image (even if it was out of the updated navigation view).
1 parent 5f89dd5 commit d07e56a

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

meshroom/ui/qml/ImageGallery/ImageGridView.qml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ GridView {
5454
function updateCurrentIndexFromSelectionViewId() {
5555
if (!sortedModel) return
5656
var idx = sortedModel.find(_currentScene.selectedViewId, "viewId")
57-
if (idx >= 0 && root.currentIndex !== idx) {
58-
root.currentIndex = idx
57+
if (idx >= 0) {
58+
if (root.currentIndex !== idx) {
59+
root.currentIndex = idx
60+
}
61+
sortedModel.selectedIndex = idx
5962
}
6063
}
6164

meshroom/ui/qml/ImageGallery/ImageListView.qml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ ListView {
5555
function updateCurrentIndexFromSelectionViewId() {
5656
if (!sortedModel) return
5757
var idx = sortedModel.find(_currentScene.selectedViewId, "viewId")
58-
if (idx >= 0 && root.currentIndex !== idx) {
59-
root.currentIndex = idx
58+
if (idx >= 0) {
59+
if (root.currentIndex !== idx) {
60+
root.currentIndex = idx
61+
}
62+
sortedModel.selectedIndex = idx
6063
}
6164
}
6265

0 commit comments

Comments
 (0)