Skip to content

Commit ac2ce53

Browse files
committed
[ui] Disable projects when the file is missing
1 parent da2adad commit ac2ce53

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

meshroom/ui/app.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import re
44
import argparse
55
import json
6+
from enum import Enum
67

78
from PySide6 import __version__ as PySideVersion
89
from PySide6 import QtCore
@@ -34,6 +35,12 @@
3435
from meshroom.ui import commands
3536

3637

38+
class FileStatus(Enum):
39+
MISSING=0
40+
EXISTS=1
41+
ERROR=2 # If the file exists but have errors like missing nodes, file content corruption...
42+
43+
3744
class MessageHandler:
3845
"""
3946
MessageHandler that translates Qt logs to Python logging system.
@@ -422,7 +429,8 @@ def _getRecentProjectFilesFromSettings(self) -> list[dict[str, str]]:
422429
settings.setArrayIndex(i)
423430
path = settings.value("filepath")
424431
if path:
425-
p = {"path": path, "thumbnail": self._retrieveThumbnailPath(path)}
432+
fileStatus = FileStatus.EXISTS if os.path.isfile(path) else FileStatus.MISSING
433+
p = {"path": path, "thumbnail": self._retrieveThumbnailPath(path), "status": fileStatus.value}
426434
projects.append(p)
427435
settings.endArray()
428436
settings.endGroup()
@@ -443,6 +451,7 @@ def _updateRecentProjectFilesThumbnails(self) -> None:
443451
for project in self._recentProjectFiles:
444452
path = project["path"]
445453
project["thumbnail"] = self._retrieveThumbnailPath(path)
454+
project["status"] = os.path.isfile(path)
446455

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

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

484493
# Only keep the first 40 projects
485494
maxNbProjects = 40

meshroom/ui/qml/Application.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ Page {
725725
id: recentFilesMenuItems
726726
model: MeshroomApp.recentProjectFiles
727727
MenuItem {
728+
enabled: modelData["status"] != 0
729+
728730
onTriggered: ensureSaved(function() {
729731
openRecentMenu.dismiss()
730732
if (_reconstruction.load(modelData["path"])) {

meshroom/ui/qml/Homepage.qml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Page {
284284
// Request latest thumbnail paths
285285
if (mainStack.currentItem instanceof Homepage)
286286
MeshroomApp.updateRecentProjectFilesThumbnails()
287-
return [{"path": null, "thumbnail": null}].concat(MeshroomApp.recentProjectFiles)
287+
return [{"path": null, "thumbnail": null, "status": null}].concat(MeshroomApp.recentProjectFiles)
288288
}
289289

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

328+
// Handle case where the file is missing
329+
property bool fileExists: modelData["status"] != 0
330+
opacity: fileExists ? 1.0 : 0.3
331+
328332
ToolTip.visible: hovered
329333
ToolTip.text: modelData["path"] ? modelData["path"] : "Open browser to select a project file"
330334

@@ -372,6 +376,7 @@ Page {
372376
id: projectContextMenu
373377

374378
MenuItem {
379+
enabled: projectDelegate.fileExists
375380
text: "Open"
376381
onTriggered: {
377382
if (_reconstruction.load(modelData["path"])) {

0 commit comments

Comments
 (0)