Skip to content

Commit 8dd513f

Browse files
committed
[ui] Homepage: Refactorize the opening of projects
Since there are two different paths to open a project (either by clicking on the project's thumbnail, or by clicking "Open" after a right-click on the project's thumbnail), the code to open it was duplicated in two different places. A single function is added to perform that operation, and is now called in both places, using the updated prototype of the `executeAfterFrameRendered` function.
1 parent fa28454 commit 8dd513f

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

meshroom/ui/qml/Homepage.qml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ Page {
2727
_window.frameSwapped.connect(onFrame)
2828
}
2929

30+
function openProject(path) {
31+
mainStack.push("Application.qml")
32+
if (_currentScene.load(path)) {
33+
MeshroomApp.addRecentProjectFile(path)
34+
} else {
35+
root.isLoading = false
36+
homepageGridView.loadingIndex = -1
37+
}
38+
}
39+
3040
onVisibleChanged: {
3141
logo.playing = false
3242
if (visible) {
@@ -458,15 +468,7 @@ Page {
458468
root.isLoading = true
459469
homepageGridView.loadingIndex = index
460470
let path = modelData["path"]
461-
root.executeAfterFrameRendered(function() {
462-
mainStack.push("Application.qml")
463-
if (_currentScene.load(path)) {
464-
MeshroomApp.addRecentProjectFile(path)
465-
} else {
466-
root.isLoading = false
467-
homepageGridView.loadingIndex = -1
468-
}
469-
})
471+
root.executeAfterFrameRendered(openProject, path)
470472
}
471473
}
472474
}
@@ -481,15 +483,7 @@ Page {
481483
root.isLoading = true
482484
homepageGridView.loadingIndex = index
483485
let path = modelData["path"]
484-
root.executeAfterFrameRendered(function() {
485-
mainStack.push("Application.qml")
486-
if (_currentScene.load(path)) {
487-
MeshroomApp.addRecentProjectFile(path)
488-
} else {
489-
root.isLoading = false
490-
homepageGridView.loadingIndex = -1
491-
}
492-
})
486+
root.executeAfterFrameRendered(openProject, path)
493487
}
494488
}
495489

0 commit comments

Comments
 (0)