update exe GUI build
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
from typing import Literal
|
||||
|
||||
from PyQt5.QtCore import QPointF, QRectF, Qt
|
||||
from PyQt5.QtGui import QColor, QIcon, QPainter, QPixmap, QPolygonF
|
||||
from PyQt5.QtGui import QColor, QIcon, QPainter, QPen, QPixmap, QPolygonF
|
||||
|
||||
TransportKind = Literal["play", "pause"]
|
||||
|
||||
@@ -48,3 +49,46 @@ def transport_icon(kind: TransportKind, color: str, *, size: int = _DEFAULT_ICON
|
||||
|
||||
painter.end()
|
||||
return QIcon(pixmap)
|
||||
|
||||
|
||||
def reset_icon(color: str, *, size: int = 16) -> QIcon:
|
||||
"""Build a circular reset / refresh arrow in ``color`` (#rrggbb)."""
|
||||
pixmap = QPixmap(size, size)
|
||||
pixmap.fill(Qt.transparent)
|
||||
|
||||
painter = QPainter(pixmap)
|
||||
painter.setRenderHint(QPainter.Antialiasing, True)
|
||||
stroke = max(1.4, size * 0.11)
|
||||
pen = QPen(QColor(color), stroke, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
|
||||
painter.setPen(pen)
|
||||
painter.setBrush(Qt.NoBrush)
|
||||
|
||||
margin = size * 0.2
|
||||
rect = QRectF(margin, margin, size - 2.0 * margin, size - 2.0 * margin)
|
||||
start_deg = 55.0
|
||||
painter.drawArc(rect, int(start_deg * 16), int(-280 * 16))
|
||||
|
||||
cx, cy = rect.center().x(), rect.center().y()
|
||||
radius = rect.width() / 2.0
|
||||
angle_rad = math.radians(start_deg)
|
||||
tip_x = cx + radius * math.cos(angle_rad)
|
||||
tip_y = cy - radius * math.sin(angle_rad)
|
||||
tangent = angle_rad + math.pi / 2.0
|
||||
head = max(2.0, size * 0.18)
|
||||
wing = max(2.0, size * 0.14)
|
||||
painter.setBrush(QColor(color))
|
||||
painter.setPen(Qt.NoPen)
|
||||
painter.drawPolygon(
|
||||
QPolygonF(
|
||||
[
|
||||
QPointF(tip_x, tip_y),
|
||||
QPointF(tip_x - head * math.cos(tangent) + wing * math.sin(tangent),
|
||||
tip_y + head * math.sin(tangent) + wing * math.cos(tangent)),
|
||||
QPointF(tip_x - head * math.cos(tangent) - wing * math.sin(tangent),
|
||||
tip_y + head * math.sin(tangent) - wing * math.cos(tangent)),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
painter.end()
|
||||
return QIcon(pixmap)
|
||||
|
||||
Reference in New Issue
Block a user