[ui] Add project to recent projects when dropping a file

This commit is contained in:
Aurore LAFAURIE 2024-07-30 11:07:45 +02:00
parent d387b7cf71
commit ea7f51cdf2
3 changed files with 15 additions and 6 deletions

View file

@ -83,7 +83,9 @@ Item {
onFilesDropped: { onFilesDropped: {
if (drop["meshroomScenes"].length == 1) { if (drop["meshroomScenes"].length == 1) {
ensureSaved(function() { ensureSaved(function() {
reconstruction.handleFilesUrl(drop, augmentSfm ? null : cameraInit) if (reconstruction.handleFilesUrl(drop, augmentSfm ? null : cameraInit)) {
MeshroomApp.addRecentProjectFile(drop["meshroomScenes"][0])
}
}) })
} else { } else {
reconstruction.handleFilesUrl(drop, augmentSfm ? null : cameraInit) reconstruction.handleFilesUrl(drop, augmentSfm ? null : cameraInit)

View file

@ -1255,7 +1255,9 @@ ApplicationWindow {
var filesByType = _reconstruction.getFilesByTypeFromDrop(drop.urls) var filesByType = _reconstruction.getFilesByTypeFromDrop(drop.urls)
if (filesByType["meshroomScenes"].length == 1) { if (filesByType["meshroomScenes"].length == 1) {
ensureSaved(function() { ensureSaved(function() {
_reconstruction.handleFilesUrl(filesByType, null, mousePosition) if (_reconstruction.handleFilesUrl(filesByType, null, mousePosition)) {
MeshroomApp.addRecentProjectFile(filesByType["meshroomScenes"][0])
}
}) })
} else { } else {
_reconstruction.handleFilesUrl(filesByType, null, mousePosition) _reconstruction.handleFilesUrl(filesByType, null, mousePosition)

View file

@ -752,9 +752,9 @@ class Reconstruction(UIGraph):
""" Get all view Ids involved in the reconstruction. """ """ Get all view Ids involved in the reconstruction. """
return [vp.viewId.value for node in self._cameraInits for vp in node.viewpoints.value] return [vp.viewId.value for node in self._cameraInits for vp in node.viewpoints.value]
@Slot("QVariantMap") @Slot("QVariantMap", result=bool)
@Slot("QVariantMap", Node) @Slot("QVariantMap", Node, result=bool)
@Slot("QVariantMap", Node, "QPoint") @Slot("QVariantMap", Node, "QPoint", result=bool)
def handleFilesUrl(self, filesByType, cameraInit=None, position=None): def handleFilesUrl(self, filesByType, cameraInit=None, position=None):
""" Handle drop events aiming to add images to the Reconstruction. """ Handle drop events aiming to add images to the Reconstruction.
This method allows to reduce process time by doing it on Python side. This method allows to reduce process time by doing it on Python side.
@ -830,7 +830,8 @@ class Reconstruction(UIGraph):
) )
) )
else: else:
self.loadUrl(filesByType["meshroomScenes"][0]) return self.loadUrl(filesByType["meshroomScenes"][0])
if not filesByType["images"] and not filesByType["videos"] and not filesByType["panoramaInfo"] and not filesByType["meshroomScenes"]: if not filesByType["images"] and not filesByType["videos"] and not filesByType["panoramaInfo"] and not filesByType["meshroomScenes"]:
@ -844,6 +845,10 @@ class Reconstruction(UIGraph):
) )
) )
# As the boolean is introduced to check if the project is loaded or not, the return value is added to the function.
# The default value is False, which means the project is not loaded.
return False
@Slot("QList<QUrl>", result="QVariantMap") @Slot("QList<QUrl>", result="QVariantMap")
def getFilesByTypeFromDrop(self, urls): def getFilesByTypeFromDrop(self, urls):
""" """