Add import downloads menu item to GUI #2246
Merged
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.
Problem
Issues with downloading sometimes lead users to download files with a browser, but if it works, there's no way to make CKAN use the files. There should be, because they're the same files regardless of who downloads them.
Changes
This pull request adds a new "Import downloaded mods..." option to GUI's (slightly reorganized) File menu:
Clicking it brings up a file selection dialog where the user can select multiple ZIP files, starting in their profile's Downloads folder:
If the user accepts that popup, CKAN switches to the progress bar tab and displays messages about its progress in importing the files. At the end, if any of the mods are compatible and not yet installed, the user is asked whether to install them:
If the user clicks Yes, then they're taken to the install flow for those selected mods:
Finally, they're given another yes/no prompt asking whether to delete the original copies of the files that were successfully imported, now that they're in the cache. The idea is that some downloads are large and would waste space if kept in multiple copies. Apparently I did not capture a screenshot of this.
Code
ConsoleUI's download importing function is moved to be an instance method of ModuleInstaller, along with some mod formatting helper functions. This is then shared between ConsoleUI and GUI.
A new file MainImport.cs is added to GUI to contain all the GUI-specific importing logic. It mainly deals with showing the popup and calls the importing function of its ModuleInstaller.
Fixes #1788.