-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from PySide6.QtWidgets import QHBoxLayout, QPushButton | ||
from src.qt.widgets.fields import FieldWidget | ||
|
||
class RatingWidget(FieldWidget): | ||
def __init__(self, title): | ||
super().__init__(title) | ||
self.layout = QHBoxLayout() | ||
Check failure on line 7 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L7
Raw output
Check failure on line 7 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L7
Raw output
|
||
self.layout.setSpacing(0) | ||
Check failure on line 8 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L8
Raw output
|
||
self.setLayout(self.layout) | ||
Check failure on line 9 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L9
Raw output
|
||
self.setObjectName("ratingBox") | ||
self.setStyleSheet("QPushButton{ color: gray; background-color: transparent; border: none;}") | ||
self.stars = [] | ||
for star in range(5): | ||
star = QPushButton("⭐") | ||
Check failure on line 14 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L14
Raw output
|
||
star.setCheckable(True) | ||
Check failure on line 15 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L15
Raw output
|
||
star.clicked.connect(self.set_rating) | ||
Check failure on line 16 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L16
Raw output
|
||
star.setStyleSheet("font-size: 30px;") | ||
Check failure on line 17 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L17
Raw output
|
||
star.setFixedSize(24, 24) | ||
Check failure on line 18 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L18
Raw output
|
||
self.stars.append(star) | ||
self.layout.addWidget(star) | ||
Check failure on line 20 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L20
Raw output
|
||
def set_rating(self, rating_index: int = None): | ||
rating_index = rating_index if rating_index is None else self.stars.index(self.sender()) | ||
Check failure on line 22 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L22
Raw output
|
||
print(rating_index) | ||
for star in range(rating_index + 1): | ||
self.stars[star].setStyleSheet("font-weight: bold; font-size: 20px;") | ||
Check failure on line 25 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L25
Raw output
|
||
for star in range(rating_index + 1, len(self.stars)): | ||
self.stars[star].setStyleSheet("font-size: 30px;") | ||
Check failure on line 27 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L27
Raw output
|
||
rating = rating_index + 1 | ||
print(rating) | ||
def modify_stars(self, totalstars): | ||
for star in self.stars: | ||
star.deleteLater() | ||
Check failure on line 32 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L32
Raw output
|
||
self.stars.clear() | ||
for star in range(totalstars): | ||
star = QPushButton("⭐") | ||
Check failure on line 35 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L35
Raw output
|
||
star.setCheckable(True) | ||
Check failure on line 36 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L36
Raw output
|
||
star.clicked.connect(self.set_rating) | ||
Check failure on line 37 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L37
Raw output
|
||
star.setStyleSheet("font-size: 30px;") | ||
Check failure on line 38 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L38
Raw output
|
||
star.setFixedSize(24, 24) | ||
Check failure on line 39 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L39
Raw output
|
||
self.stars.append(star) | ||
self.layout.addWidget(star) | ||
Check failure on line 41 in tagstudio/src/qt/widgets/rating.py GitHub Actions / mypy[mypy] tagstudio/src/qt/widgets/rating.py#L41
Raw output
|