Red dot for missing files, green dot for library items

- Missing file indicator (red dot) for NAS/lost files, QSS-controllable
  via qproperty-missingColor
- Library items now show green saved dot
- Missing files detected on refresh and marked red
This commit is contained in:
pax 2026-04-05 02:37:03 -05:00
parent 768deca348
commit 8d6d03ac59
2 changed files with 22 additions and 3 deletions

View File

@ -27,9 +27,10 @@ class ThumbnailWidget(QWidget):
double_clicked = Signal(int) double_clicked = Signal(int)
right_clicked = Signal(int, object) # index, QPoint right_clicked = Signal(int, object) # index, QPoint
# QSS-controllable dot colors: qproperty-savedColor / qproperty-bookmarkedColor # QSS-controllable dot colors
_saved_color = QColor("#22cc22") _saved_color = QColor("#22cc22")
_bookmarked_color = QColor("#ffcc00") _bookmarked_color = QColor("#ffcc00")
_missing_color = QColor("#ff4444")
def _get_saved_color(self): return self._saved_color def _get_saved_color(self): return self._saved_color
def _set_saved_color(self, c): self._saved_color = QColor(c) if isinstance(c, str) else c def _set_saved_color(self, c): self._saved_color = QColor(c) if isinstance(c, str) else c
@ -39,6 +40,10 @@ class ThumbnailWidget(QWidget):
def _set_bookmarked_color(self, c): self._bookmarked_color = QColor(c) if isinstance(c, str) else c def _set_bookmarked_color(self, c): self._bookmarked_color = QColor(c) if isinstance(c, str) else c
bookmarkedColor = Property(QColor, _get_bookmarked_color, _set_bookmarked_color) bookmarkedColor = Property(QColor, _get_bookmarked_color, _set_bookmarked_color)
def _get_missing_color(self): return self._missing_color
def _set_missing_color(self, c): self._missing_color = QColor(c) if isinstance(c, str) else c
missingColor = Property(QColor, _get_missing_color, _set_missing_color)
def __init__(self, index: int, parent: QWidget | None = None) -> None: def __init__(self, index: int, parent: QWidget | None = None) -> None:
super().__init__(parent) super().__init__(parent)
self.index = index self.index = index
@ -47,6 +52,7 @@ class ThumbnailWidget(QWidget):
self._multi_selected = False self._multi_selected = False
self._bookmarked = False self._bookmarked = False
self._saved_locally = False self._saved_locally = False
self._missing = False
self._hover = False self._hover = False
self._drag_start: QPoint | None = None self._drag_start: QPoint | None = None
self._cached_path: str | None = None self._cached_path: str | None = None
@ -79,6 +85,10 @@ class ThumbnailWidget(QWidget):
self._saved_locally = saved self._saved_locally = saved
self.update() self.update()
def set_missing(self, missing: bool) -> None:
self._missing = missing
self.update()
def set_prefetch_progress(self, progress: float) -> None: def set_prefetch_progress(self, progress: float) -> None:
"""Set prefetch progress: -1 = hide, 0.0-1.0 = progress.""" """Set prefetch progress: -1 = hide, 0.0-1.0 = progress."""
self._prefetch_progress = progress self._prefetch_progress = progress
@ -120,7 +130,7 @@ class ThumbnailWidget(QWidget):
y = (self.height() - self._pixmap.height()) // 2 y = (self.height() - self._pixmap.height()) // 2
p.drawPixmap(x, y, self._pixmap) p.drawPixmap(x, y, self._pixmap)
# Saved dot + bookmark star (right-aligned, star right of dot) # Indicators: missing (red) / saved (green) dot + bookmark star
indicator_x = self.width() - 4 indicator_x = self.width() - 4
if self._bookmarked: if self._bookmarked:
from PySide6.QtGui import QFont from PySide6.QtGui import QFont
@ -128,7 +138,12 @@ class ThumbnailWidget(QWidget):
p.setFont(QFont(p.font().family(), 8)) p.setFont(QFont(p.font().family(), 8))
indicator_x -= 11 indicator_x -= 11
p.drawText(indicator_x, 12, "\u2605") p.drawText(indicator_x, 12, "\u2605")
if self._saved_locally: if self._missing:
p.setPen(Qt.PenStyle.NoPen)
p.setBrush(self._missing_color)
indicator_x -= 9
p.drawEllipse(indicator_x, 4, 7, 7)
elif self._saved_locally:
p.setPen(Qt.PenStyle.NoPen) p.setPen(Qt.PenStyle.NoPen)
p.setBrush(self._saved_color) p.setBrush(self._saved_color)
indicator_x -= 9 indicator_x -= 9

View File

@ -105,6 +105,10 @@ class LibraryView(QWidget):
for i, (filepath, thumb) in enumerate(zip(self._files, thumbs)): for i, (filepath, thumb) in enumerate(zip(self._files, thumbs)):
thumb._cached_path = str(filepath) thumb._cached_path = str(filepath)
thumb.setToolTip(filepath.name) thumb.setToolTip(filepath.name)
if not filepath.exists():
thumb.set_missing(True)
continue
thumb.set_saved_locally(True)
cached_thumb = lib_thumb_dir / f"{filepath.stem}.jpg" cached_thumb = lib_thumb_dir / f"{filepath.stem}.jpg"
if cached_thumb.exists(): if cached_thumb.exists():
pix = QPixmap(str(cached_thumb)) pix = QPixmap(str(cached_thumb))