[ui] Save the last folders of imported images across sessions

Save up to 3 folder locations from which images have been imported.
These folder locations will be saved across Meshroom sessions, in
a similar fashion as the "Recent Files" entries.
If no folder location has been saved (or if all saved folder locations
are invalid), we fall back to the default behaviour: if a project with
images has been opened before the "Import Images" action is called, then
the base folder will be the folder containing the opened project's
images.
This commit is contained in:
Candice Bentéjac 2023-01-10 16:34:14 +01:00
parent abd9582aa7
commit 1b5e33c9ef
2 changed files with 96 additions and 1 deletions

View file

@ -46,7 +46,18 @@ ApplicationWindow {
SystemPalette { id: activePalette }
SystemPalette { id: disabledPalette; colorGroup: SystemPalette.Disabled }
property url imagesFolder: ""
property url imagesFolder: {
var recentImportedImagesFolders = MeshroomApp.recentImportedImagesFolders
if (recentImportedImagesFolders.length > 0) {
for (var i = 0; i < recentImportedImagesFolders.length; i++) {
if (Filepath.exists(recentImportedImagesFolders[i]))
return Filepath.stringToUrl(recentImportedImagesFolders[i])
else
MeshroomApp.removeRecentImportedImagesFolder(Filepath.stringToUrl(recentImportedImagesFolders[i]))
}
}
return ""
}
Settings {
id: settings_General
@ -331,6 +342,7 @@ ApplicationWindow {
onAccepted: {
_reconstruction.importImagesUrls(importImagesDialog.fileUrls)
imagesFolder = Filepath.dirname(importImagesDialog.fileUrls[0])
MeshroomApp.addRecentImportedImagesFolder(imagesFolder)
}
}
@ -480,6 +492,7 @@ ApplicationWindow {
function initFileDialogFolder(dialog, importImages = false) {
let folder = "";
if (_reconstruction.graph && _reconstruction.graph.filepath) {
folder = Filepath.stringToUrl(Filepath.dirname(_reconstruction.graph.filepath));
if (imagesFolder.toString() === "" && workspaceView.imageGallery.galleryGrid.itemAtIndex(0) !== null) {