CID: Connect txtInstallDirectory.textChanged
sooner
#456
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.
Fixes an issue I found when investigating another issue relating to the Custom Install Directory dialog.
Overview
This PR connects
txtInstallDirectory.textChanged
sooner, so that it can get triggered when we calltxtInstallDirectory.setText
.textChanged
does validate text that is set programmatically, but won't do anything for our case if we connect it after we already set the text. This fixes an issue where when opening the Custom Install Directory dialog with a selected Custom Install Directory, the pre-populated path in thetxtInstallDirectory
Line Edit would not be seen as valid (because thetextChanged
signal to validate the path was not connected until after the text was set, so it did not know to validate the path on open of the dialog) and so the "Save" button would be kept as disabled.Background
Currently, when you enter a path manually into the Custom Install Directory's
txtInstallDirectory
Line Edit, it will validate the path and dynamically enable/disable the "Save" button based on whether the path is valid (exists and that we have write access to the folder). We usetextChanged
because this value can also be updated programmatically based on the File Picker that can appear as well. By default, this button is disabled, because by default thetxtInstallDirectory
Line Edit is blank, so we don't want "Save" to be enabled.However, if a Custom Install Directory is already saved, when opening the Custom Install Directory dialog, the path is populated, but the "Save" button is kept as disabled. This is because we connect the
txtInstallDirectory.textChanged
signal after we calltxtInstallDirectory.setText
. The order is like this:btnSave
is disabled by defaulttxtInstallDirectory
text is populated to the current Custom Install Directory pathtxtInstallDirectory.textChanged
is connected to validate the text in the field, but will not validate any path entered before this connection.btnSave
is kept as disabled until the text in thetxtInstallDirectory
dialog is updated again (i.e. removing the trailing forward-slash).Solution
The solution here is to connect
txtInstallDirectory.textChanged
before callingtxtInstallDirectory.setText
, which allows calls tosetText
to be validated by thetextChanged
action.The effect of this results in the following behaviour:
Before (
main
)After (This PR)
Likely there is no reason why a user would want to save the path again to the pre-populated path, but I don't think the "Save" button needs to care about that. When the path is valid, even if it is a pre-populated path, the "Save" button should not be disabled. If I found this confusing behaviour I am sure others have too. 😄
Thanks!