Refactor HVideoTool to support project-based workflow: introduced project management features, updated UI for project handling, and enhanced documentation in README and CLAUDE.md. The tool now organizes images and settings into projects, improving usability and detection caching.

This commit is contained in:
Leonid Pershin
2026-06-07 04:53:27 +03:00
parent 7f0121b7df
commit e27dfdf518
27 changed files with 2998 additions and 387 deletions
+31 -2
View File
@@ -1,7 +1,9 @@
"""Persist a handful of user choices to ~/HVideoTool/settings.json.
Slimmed down for the image-inspector tool: it remembers the detector, the model
path, the overlay threshold, and the last opened folder.
For the project-based tool this file holds the **defaults for new projects** (the
detector, model path, overlay threshold, restore engine) plus app-level state: the
last opened project, the recent-projects list, and the last directory used in file
dialogs. Per-project settings live in each project's ``project.json``, not here.
"""
from __future__ import annotations
@@ -66,3 +68,30 @@ def set_last_dir(path: str) -> None:
data = _read()
data["last_dir"] = path
_write(data)
def last_project() -> str | None:
return _read().get("last_project")
def set_last_project(path: str) -> None:
data = _read()
data["last_project"] = path
_write(data)
_RECENTS_CAP = 10
def recent_projects() -> list[str]:
recents = _read().get("recent_projects", [])
return [p for p in recents if isinstance(p, str)]
def add_recent_project(path: str) -> None:
"""Push ``path`` to the front of the recent-projects list (deduped, capped)."""
data = _read()
recents = [p for p in data.get("recent_projects", []) if isinstance(p, str) and p != path]
recents.insert(0, path)
data["recent_projects"] = recents[:_RECENTS_CAP]
_write(data)