Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions meshroom/ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import argparse
import json
from enum import Enum

from PySide6 import __version__ as PySideVersion
from PySide6 import QtCore
Expand Down Expand Up @@ -34,6 +35,12 @@
from meshroom.ui import commands


class FileStatus(Enum):
MISSING=0
EXISTS=1
ERROR=2 # If the file exists but have errors like missing nodes, file content corruption...


class MessageHandler:
"""
MessageHandler that translates Qt logs to Python logging system.
Expand Down Expand Up @@ -422,7 +429,8 @@ def _getRecentProjectFilesFromSettings(self) -> list[dict[str, str]]:
settings.setArrayIndex(i)
path = settings.value("filepath")
if path:
p = {"path": path, "thumbnail": self._retrieveThumbnailPath(path)}
fileStatus = FileStatus.EXISTS if os.path.isfile(path) else FileStatus.MISSING
p = {"path": path, "thumbnail": self._retrieveThumbnailPath(path), "status": fileStatus.value}
projects.append(p)
settings.endArray()
settings.endGroup()
Expand All @@ -443,6 +451,7 @@ def _updateRecentProjectFilesThumbnails(self) -> None:
for project in self._recentProjectFiles:
path = project["path"]
project["thumbnail"] = self._retrieveThumbnailPath(path)
project["status"] = os.path.isfile(path)

@Slot(str)
@Slot(QUrl)
Expand Down Expand Up @@ -479,7 +488,7 @@ def addRecentProjectFile(self, projectFile) -> None:
del projects[idx] # If so, delete its entry

# Insert the newest entry at the top of the list
projects.insert(0, {"path": projectFileNorm, "thumbnail": ""})
projects.insert(0, {"path": projectFileNorm, "thumbnail": "", "status": FileStatus.EXISTS})

# Only keep the first 40 projects
maxNbProjects = 40
Expand Down
4 changes: 2 additions & 2 deletions meshroom/ui/qml/Application.qml
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,12 @@ Page {
id: recentFilesMenuItems
model: MeshroomApp.recentProjectFiles
MenuItem {
enabled: modelData["status"] != 0

onTriggered: ensureSaved(function() {
openRecentMenu.dismiss()
if (_reconstruction.load(modelData["path"])) {
MeshroomApp.addRecentProjectFile(modelData["path"])
} else {
MeshroomApp.removeRecentProjectFile(modelData["path"])
}
})

Expand Down
9 changes: 6 additions & 3 deletions meshroom/ui/qml/Homepage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Page {
// Request latest thumbnail paths
if (mainStack.currentItem instanceof Homepage)
MeshroomApp.updateRecentProjectFilesThumbnails()
return [{"path": null, "thumbnail": null}].concat(MeshroomApp.recentProjectFiles)
return [{"path": null, "thumbnail": null, "status": null}].concat(MeshroomApp.recentProjectFiles)
}

// Update grid item when corresponding thumbnail is computed
Expand Down Expand Up @@ -325,6 +325,10 @@ Page {
height: gridView.cellHeight * 0.95 - project.height
width: gridView.cellWidth * 0.9

// Handle case where the file is missing
property bool fileExists: modelData["status"] != 0
opacity: fileExists ? 1.0 : 0.3

ToolTip.visible: hovered
ToolTip.text: modelData["path"] ? modelData["path"] : "Open browser to select a project file"

Expand Down Expand Up @@ -361,8 +365,6 @@ Page {
mainStack.push("Application.qml")
if (_reconstruction.load(modelData["path"])) {
MeshroomApp.addRecentProjectFile(modelData["path"])
} else {
MeshroomApp.removeRecentProjectFile(modelData["path"])
}
}

Expand All @@ -374,6 +376,7 @@ Page {
id: projectContextMenu

MenuItem {
enabled: projectDelegate.fileExists
text: "Open"
onTriggered: {
if (_reconstruction.load(modelData["path"])) {
Expand Down