Persist remote connect dialog options (#18601)
Closes #18512
Summary of the issue:
Since most users use their device as either follower or leader
consistently, NVDA Remote Access should remember their selection.
The same can also be said of the server type and port to use for
self-hosted servers.
Description of user facing changes:
The "Connect to Another Computer" dialog persists the selection of the
"Mode", "Server" and "Port" controls.
Description of developer facing changes:
NVDA now sets up `wx.lib.agw.persist` as follows:
* persisted GUI state is saved to "guiState.ini" in the NVDA config
directory.
* If `NVDAState.shouldWriteToDisk` returns `False`, saving is disabled.
Description of development approach:
* Set up the `PersistenceManager` singleton in `gui.initialize`. Free it
in `gui.terminate` out of an abundance of caution.
* Add an (internal) list of controls that should be persisted to
`_remoteClient.dialogs.DirectConnectDialog`.
* Add (internal) methods to the same class to register and restore
state, save state, and unregister these controls.
* Register and restore state on init, save state on OK, and unregister
on dialog destruction (used instead of window close as this is not fired
on modal dialogs).
Testing strategy:
Connected to remote a number of times across a number of NVDA restarts
and ensured mode was remembered.
Manually edited the `guiState.ini` file to contain illegal values, and
ran NVDA to ensure the defaults were used in this case.
Ran NVDA with the `--launcher` flag and ensured that GUI state was read
but not written.
Known issues with pull request:
None