Skip to content

Commit

Permalink
[ui] ImageGallery: display the correct image in the Viewer after a re…
Browse files Browse the repository at this point in the history
…moval

When an image is removed from the gallery, the adjacent one is
automatically selected in the GridView. However, as the index in the
GridView would not change (the adjacent image taking the place of the
removed one), the 2D viewer would not receive any update and no more image
would be displayed. Even if the index in the GridView remains the same,
the 2D viewer now is updated with the newly selected image.
  • Loading branch information
cbentejac committed Nov 15, 2022
1 parent 5e441c9 commit 3f8f1c4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions meshroom/ui/qml/ImageGallery/ImageGallery.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ Panel {

onViewpointsChanged: {
// The model has been updated, but the GridView is yet to be filled with the new data: reset the grid index
if (grid.count == 0 && grid.count != viewpoints.count)
if (grid.count == 0 && grid.count != viewpoints.count) {
grid.currentIndex = -1;
}
}
}

Expand Down Expand Up @@ -168,10 +169,14 @@ Panel {
}

onCountChanged: {
/* If the grid index is -1, then it has been reset when the model was updated and the grid emptied
Set it to 0 to select the first element now that it is filled */
if (grid.currentIndex == -1 && grid.count > 0) {
/* If the grid index is -1, then it has been reset when the model was updated and the grid emptied
Set it to 0 to select the first element now that it is filled */
grid.currentIndex = 0
} else {
/* The count is updated but the current index is valid: an image has been added or removed. The
index remains unchanged, but the selected image has changed. */
grid.currentIndexChanged()
}
}

Expand Down

0 comments on commit 3f8f1c4

Please sign in to comment.