[ui] Preserve last CameraInit
index when updating the CameraInits list
#2145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Prior to this PR, when a
CameraInit
node was added to or removed from the list ofCameraInit
nodes, the activeCameraInit
was always reset to the first one in the list, independently from its previous value. This meant that whenever aCameraInit
node was added to or removed from the graph while the Image Gallery was displaying aCameraInit
node that was not the first one in the list, the Image Gallery was automatically updated to display the firstCameraInit
node without any intervention from the user, as shown below:This pull request changes that behaviour by only modifying the active
CameraInit
node if noCameraInit
node has been assigned yet, or if the activeCameraInit
node does not exist anymore (meaning it has been removed).This requires to emit the
cameraInitChanged()
signal every single time the list of existingCameraInit
nodes is modified even if the active one remains the same, and to connect it to the ImageGallery in order to ensure the index from the combo box always corresponds to the currently activeCameraInit
node. Indeed, when the list of CameraInits is updated, themodel for the combo box is reset, and it needs to be re-updated with the correct non-default value.