QSS-controllable favorite/saved indicator dots
ThumbnailWidget now exposes savedColor and favoritedColor as Qt properties. Set via QSS: qproperty-savedColor / qproperty-favoritedColor
This commit is contained in:
parent
074d75770e
commit
243a889fc1
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import Qt, Signal, QSize, QRect, QMimeData, QUrl, QPoint
|
||||
from PySide6.QtCore import Qt, Signal, QSize, QRect, QMimeData, QUrl, QPoint, Property
|
||||
from PySide6.QtGui import QPixmap, QPainter, QColor, QPen, QKeyEvent, QWheelEvent, QDrag
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget,
|
||||
@ -27,6 +27,18 @@ class ThumbnailWidget(QWidget):
|
||||
double_clicked = Signal(int)
|
||||
right_clicked = Signal(int, object) # index, QPoint
|
||||
|
||||
# QSS-controllable dot colors: qproperty-savedColor / qproperty-favoritedColor
|
||||
_saved_color = QColor("#22cc22")
|
||||
_favorited_color = QColor("#ff4444")
|
||||
|
||||
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
|
||||
savedColor = Property(QColor, _get_saved_color, _set_saved_color)
|
||||
|
||||
def _get_favorited_color(self): return self._favorited_color
|
||||
def _set_favorited_color(self, c): self._favorited_color = QColor(c) if isinstance(c, str) else c
|
||||
favoritedColor = Property(QColor, _get_favorited_color, _set_favorited_color)
|
||||
|
||||
def __init__(self, index: int, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.index = index
|
||||
@ -111,10 +123,7 @@ class ThumbnailWidget(QWidget):
|
||||
# Favorite/saved indicator
|
||||
if self._favorited:
|
||||
p.setPen(Qt.PenStyle.NoPen)
|
||||
if self._saved_locally:
|
||||
p.setBrush(QColor("#22cc22"))
|
||||
else:
|
||||
p.setBrush(QColor("#ff4444"))
|
||||
p.setBrush(self._saved_color if self._saved_locally else self._favorited_color)
|
||||
p.drawEllipse(self.width() - 14, 4, 10, 10)
|
||||
|
||||
# Multi-select checkmark
|
||||
|
||||
@ -220,6 +220,15 @@ QLabel {
|
||||
}
|
||||
```
|
||||
|
||||
### Thumbnail Indicator Dots
|
||||
|
||||
```css
|
||||
ThumbnailWidget {
|
||||
qproperty-savedColor: #22cc22; /* green dot: saved to library */
|
||||
qproperty-favoritedColor: #ff4444; /* red dot: favorited but not saved */
|
||||
}
|
||||
```
|
||||
|
||||
## States
|
||||
|
||||
| State | Description |
|
||||
@ -236,5 +245,5 @@ QLabel {
|
||||
- `selection-background-color` on `QWidget` controls the **grid thumbnail selection highlight**
|
||||
- Setting a custom QSS automatically switches to the Fusion Qt style for consistent rendering
|
||||
- Tag category colors (Artist, Character, etc.) in the info panel are set in code, not via QSS
|
||||
- The favorite/saved dot indicators on thumbnails are painted in code
|
||||
- Favorite/saved dots are QSS-controllable via `qproperty-savedColor` and `qproperty-favoritedColor` on `ThumbnailWidget`
|
||||
- Use `QLabel { background: transparent; }` to prevent labels from getting opaque backgrounds
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user