Skip to content

Fix folder picker opening twice on first cloud synchronization - #839

Open
tristan0x wants to merge 2 commits into
opengisch:masterfrom
tristan0x:tristan/fix/dir-dlg-twice
Open

tristan0x wants to merge 2 commits into
opengisch:masterfrom
tristan0x:tristan/fix/dir-dlg-twice

Conversation

@tristan0x

Copy link
Copy Markdown

Fixes #753

On the first synchronization of a cloud project, clicking "..." on the local directory page opened the folder picker, and cancelling it immediately opened a second one.

Changes

  • Connect the local directory button once. The clicked connection was made in show_project_local_dir_selection(), which runs on every showEvent. The dialog is shown twice, by show() in show_transfer_dialog() and then by open() in show_sync_popup(), so the button ended up connected twice. The connection now lives in the constructor.
  • Keep the current directory on cancel. select_folder() no longer overwrites the line edit with an empty string when the picker is cancelled. The picker also gets a parent window and a "Select directory" caption instead of Qt's generic "Find Directory". This also applies to the QField directory picker in the synchronize dialog.

How to test

  1. Open a cloud project that has never been synchronized locally and start the synchronization.
  2. On the local directory page, click "..." and then Cancel: no second picker appears and the pre-filled path is kept.
  3. Click "..." again and pick a folder: the field is updated.
  4. In "Synchronize from QField", check that the QField directory picker behaves the same way.

Out of scope

The issue also mentions that typing a directory name does not offer to create it. That comes from Qt's native QFileDialog, which only accepts existing directories. The typed directory is already created with os.makedirs when the synchronization starts.

The connection was made in `showEvent`, which fires on each `show()` and
`open()`, so the folder picker opened twice per click.

Fixes opengisch#753
Cancelling the picker no longer clears the line edit. The picker also gets
a parent window and a "Select directory" caption.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Initial synchronize from QGIS Desktop: Find Directory reappears on Cancel

1 participant