Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions BlocksScreen/lib/panels/widgets/optionCardWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def setMode(self, double_mode: bool = False):
def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
"""Re-implemented method, paint widget"""
# Rounded background edges
self.background_path = QtGui.QPainterPath()
self.background_path.addRoundedRect(
background_path = QtGui.QPainterPath()
background_path.addRoundedRect(
self.rect().toRectF(), 20.0, 20.0, QtCore.Qt.SizeMode.AbsoluteSize
)

Expand All @@ -167,7 +167,7 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
painter.setRenderHint(painter.RenderHint.Antialiasing)
painter.setRenderHint(painter.RenderHint.SmoothPixmapTransform)
painter.setRenderHint(painter.RenderHint.LosslessImageRendering)
painter.fillPath(self.background_path, bg_color)
painter.fillPath(background_path, bg_color)
if self.underMouse():
_pen = QtGui.QPen()
_pen.setStyle(QtCore.Qt.PenStyle.SolidLine)
Expand All @@ -193,7 +193,7 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
_gradient.setColorAt(1, _color3)
painter.setBrush(_gradient)
painter.setPen(QtCore.Qt.PenStyle.NoPen)
painter.fillPath(self.background_path, painter.brush())
painter.fillPath(background_path, painter.brush())

painter.end()

Expand All @@ -216,6 +216,7 @@ def _setupUi(self, option_card):
self.option_icon = IconButton(parent=option_card)
self.option_icon.setMinimumSize(QtCore.QSize(200, 150))
self.option_icon.setObjectName("option_icon")
self.option_icon.setScaledContents(True)
_button_font = QtGui.QFont()
_button_font.setBold(True)
_button_font.setPointSize(20)
Expand Down
45 changes: 36 additions & 9 deletions BlocksScreen/lib/utils/blocks_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ def __init__(self, parent: QtWidgets.QWidget = None, *args, **kwargs):
QtWidgets.QSizePolicy.Policy.MinimumExpanding,
QtWidgets.QSizePolicy.Policy.MinimumExpanding,
)

self._glow_color: QtGui.QColor = QtGui.QColor("#E95757")
self._animation_speed: int = 300
self.glow_animation = QtCore.QPropertyAnimation(self, b"glow_color")
self.glow_animation.setEasingCurve(QtCore.QEasingCurve().Type.InOutQuart)
self.glow_animation.setDuration(self.animation_speed)

self.glow_animation.finished.connect(self.change_glow_direction)
self.glow_animation.finished.connect(self.repaint)

self.total_scroll_width: float = 0.0
self.text_width: float = 0.0
self.label_width: float = 0.0
self.icon_margin: int = 5
self.first_run = True

def resizeEvent(self, a0: QtGui.QResizeEvent) -> None:
Expand Down Expand Up @@ -203,17 +201,46 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
qp.fillRect(rect, self._background_color)

if self.icon_pixmap:
icon_rect = QtCore.QRectF(0, 0, self.height(), self.height())
scaled = self.icon_pixmap.scaled(
icon_rect = QtCore.QRectF(
0.0 + self.icon_margin,
0.0 + self.icon_margin,
self.width() - self.icon_margin,
self.height() - self.icon_margin,
)
_icon_scaled = self.icon_pixmap.scaled(
icon_rect.size().toSize(),
QtCore.Qt.AspectRatioMode.KeepAspectRatio,
QtCore.Qt.TransformationMode.SmoothTransformation,
)
qp.drawPixmap(icon_rect.toRect(), scaled)
scaled_width = _icon_scaled.width()
scaled_height = _icon_scaled.height()
adjusted_x = (icon_rect.width() - scaled_width) // 2.0
adjusted_y = (icon_rect.height() - scaled_height) // 2.0
adjusted_icon = QtCore.QRectF(
icon_rect.x() + adjusted_x,
icon_rect.y() + adjusted_y,
scaled_width,
scaled_height,
)
qp.drawPixmap(adjusted_icon, _icon_scaled, _icon_scaled.rect().toRectF())
if self.glow_animation.state() == self.glow_animation.State.Running:
path = QtGui.QPainterPath()
path.addRoundedRect(QtCore.QRectF(rect), 10, 10)
qp.fillPath(path, self.glow_color)
big_rect = QtGui.QPainterPath()
rect = self.contentsRect().toRectF()
big_rect.addRoundedRect(rect, 10.0, 10.0, QtCore.Qt.SizeMode.AbsoluteSize)
sub_rect = QtCore.QRectF(
(rect.width() - rect.width() * 0.99) / 2,
(rect.height() - rect.height() * 0.85) / 2,
rect.width() * 0.99,
rect.height() * 0.85,
)
sub_path = QtGui.QPainterPath()
sub_path.addRoundedRect(
sub_rect, 10.0, 10.0, QtCore.Qt.SizeMode.AbsoluteSize
)
subtracted = big_rect.subtracted(sub_path)
qp.setCompositionMode(qp.CompositionMode.CompositionMode_SourceOver)
subtracted.setFillRule(QtCore.Qt.FillRule.OddEvenFill)
qp.fillPath(subtracted, self.glow_color)
if self._text:
text_option = QtGui.QTextOption(self.alignment())
text_option.setWrapMode(QtGui.QTextOption.WrapMode.NoWrap)
Expand Down
Loading