Skip to content

Commit

Permalink
Add field widget for rating field type
Browse files Browse the repository at this point in the history
- Needs remove and edit callbacks (must not require you to open edit menu)
  • Loading branch information
Nginearing authored Nov 29, 2024
1 parent 8fdb44b commit 31f3842
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tagstudio/src/qt/widgets/rating.py
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

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L7

Cannot assign to a method [method-assign]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:7:9: error: Cannot assign to a method  [method-assign]

Check failure on line 7 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L7

Incompatible types in assignment (expression has type "QHBoxLayout", variable has type "Callable[[], QLayout]") [assignment]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:7:23: error: Incompatible types in assignment (expression has type "QHBoxLayout", variable has type "Callable[[], QLayout]")  [assignment]
self.layout.setSpacing(0)

Check failure on line 8 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L8

"Callable[[], QLayout]" has no attribute "setSpacing" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:8:9: error: "Callable[[], QLayout]" has no attribute "setSpacing"  [attr-defined]
self.setLayout(self.layout)

Check failure on line 9 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L9

Argument 1 to "setLayout" of "QWidget" has incompatible type "Callable[[], QLayout]"; expected "QLayout" [arg-type]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:9:24: error: Argument 1 to "setLayout" of "QWidget" has incompatible type "Callable[[], QLayout]"; expected "QLayout"  [arg-type]
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

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L14

Incompatible types in assignment (expression has type "QPushButton", variable has type "int") [assignment]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:14:20: error: Incompatible types in assignment (expression has type "QPushButton", variable has type "int")  [assignment]
star.setCheckable(True)

Check failure on line 15 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L15

"int" has no attribute "setCheckable" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:15:13: error: "int" has no attribute "setCheckable"  [attr-defined]
star.clicked.connect(self.set_rating)

Check failure on line 16 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L16

"int" has no attribute "clicked" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:16:13: error: "int" has no attribute "clicked"  [attr-defined]
star.setStyleSheet("font-size: 30px;")

Check failure on line 17 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L17

"int" has no attribute "setStyleSheet" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:17:13: error: "int" has no attribute "setStyleSheet"  [attr-defined]
star.setFixedSize(24, 24)

Check failure on line 18 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L18

"int" has no attribute "setFixedSize" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:18:13: error: "int" has no attribute "setFixedSize"  [attr-defined]
self.stars.append(star)
self.layout.addWidget(star)

Check failure on line 20 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L20

"Callable[[], QLayout]" has no attribute "addWidget" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:20:13: error: "Callable[[], QLayout]" has no attribute "addWidget"  [attr-defined]
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

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L22

Argument 1 to "index" of "list" has incompatible type "QObject"; expected "int" [arg-type]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:22:83: error: Argument 1 to "index" of "list" has incompatible type "QObject"; expected "int"  [arg-type]
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

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L25

"int" has no attribute "setStyleSheet" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:25:13: error: "int" has no attribute "setStyleSheet"  [attr-defined]
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

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L27

"int" has no attribute "setStyleSheet" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:27:13: error: "int" has no attribute "setStyleSheet"  [attr-defined]
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

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L32

"int" has no attribute "deleteLater" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:32:13: error: "int" has no attribute "deleteLater"  [attr-defined]
self.stars.clear()
for star in range(totalstars):
star = QPushButton("⭐")

Check failure on line 35 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L35

Incompatible types in assignment (expression has type "QPushButton", variable has type "int") [assignment]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:35:20: error: Incompatible types in assignment (expression has type "QPushButton", variable has type "int")  [assignment]
star.setCheckable(True)

Check failure on line 36 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L36

"int" has no attribute "setCheckable" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:36:13: error: "int" has no attribute "setCheckable"  [attr-defined]
star.clicked.connect(self.set_rating)

Check failure on line 37 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L37

"int" has no attribute "clicked" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:37:13: error: "int" has no attribute "clicked"  [attr-defined]
star.setStyleSheet("font-size: 30px;")

Check failure on line 38 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L38

"int" has no attribute "setStyleSheet" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:38:13: error: "int" has no attribute "setStyleSheet"  [attr-defined]
star.setFixedSize(24, 24)

Check failure on line 39 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L39

"int" has no attribute "setFixedSize" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:39:13: error: "int" has no attribute "setFixedSize"  [attr-defined]
self.stars.append(star)
self.layout.addWidget(star)

Check failure on line 41 in tagstudio/src/qt/widgets/rating.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] tagstudio/src/qt/widgets/rating.py#L41

"Callable[[], QLayout]" has no attribute "addWidget" [attr-defined]
Raw output
/home/runner/work/TagStudioTesting/TagStudioTesting/tagstudio/src/qt/widgets/rating.py:41:13: error: "Callable[[], QLayout]" has no attribute "addWidget"  [attr-defined]

0 comments on commit 31f3842

Please sign in to comment.