Replace text buttons with SVG icons, rebrand to Getting To It
This commit is contained in:
@@ -0,0 +1,256 @@
|
||||
# icons.py -- QPainter-drawn icons for Radio Panel
|
||||
#
|
||||
# Each function takes (color: str) and returns a QIcon painted at 24x24.
|
||||
# All icons are simple geometric shapes -- clean, broadcast-console look.
|
||||
|
||||
from PySide6.QtGui import QPainter, QColor, QPen, QBrush, QPixmap, QIcon, QPainterPath
|
||||
from PySide6.QtCore import Qt, QRectF, QPointF
|
||||
|
||||
_S = 24
|
||||
|
||||
|
||||
def _make_icon(paint_fn, color: str) -> QIcon:
|
||||
pix = QPixmap(_S, _S)
|
||||
pix.fill(Qt.transparent)
|
||||
p = QPainter(pix)
|
||||
p.setRenderHint(QPainter.Antialiasing)
|
||||
paint_fn(p, QRectF(2, 2, _S - 4, _S - 4), QColor(color))
|
||||
p.end()
|
||||
return QIcon(pix)
|
||||
|
||||
|
||||
# ── Transport Icons ────────────────────────────────────────────────
|
||||
|
||||
def icon_play(color: str = "#00ff41") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
p.setPen(Qt.NoPen)
|
||||
p.setBrush(c)
|
||||
path = QPainterPath()
|
||||
path.moveTo(r.left(), r.top())
|
||||
path.lineTo(r.right(), r.center().y())
|
||||
path.lineTo(r.left(), r.bottom())
|
||||
path.closeSubpath()
|
||||
p.drawPath(path)
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_pause(color: str = "#ffffff") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
p.setPen(Qt.NoPen)
|
||||
p.setBrush(c)
|
||||
w = r.width() * 0.32
|
||||
p.drawRect(QRectF(r.left(), r.top(), w, r.height()))
|
||||
p.drawRect(QRectF(r.right() - w, r.top(), w, r.height()))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_stop(color: str = "#ff4444") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
p.setPen(Qt.NoPen)
|
||||
p.setBrush(c)
|
||||
margin = r.width() * 0.18
|
||||
p.drawRect(r.adjusted(margin, margin, -margin, -margin))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_skip_start(color: str = "#ffffff") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
p.setPen(Qt.NoPen)
|
||||
p.setBrush(c)
|
||||
w = r.width() * 0.35
|
||||
# Two triangles pointing left
|
||||
path = QPainterPath()
|
||||
path.moveTo(r.right(), r.top())
|
||||
path.lineTo(r.left(), r.center().y())
|
||||
path.lineTo(r.right(), r.bottom())
|
||||
path.closeSubpath()
|
||||
p.drawPath(path)
|
||||
path2 = QPainterPath()
|
||||
path2.moveTo(r.center().x(), r.top())
|
||||
path2.lineTo(r.left(), r.center().y())
|
||||
path2.lineTo(r.center().x(), r.bottom())
|
||||
path2.closeSubpath()
|
||||
p.drawPath(path2)
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_skip_end(color: str = "#ffffff") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
p.setPen(Qt.NoPen)
|
||||
p.setBrush(c)
|
||||
path = QPainterPath()
|
||||
path.moveTo(r.left(), r.top())
|
||||
path.lineTo(r.right(), r.center().y())
|
||||
path.lineTo(r.left(), r.bottom())
|
||||
path.closeSubpath()
|
||||
p.drawPath(path)
|
||||
path2 = QPainterPath()
|
||||
path2.moveTo(r.center().x(), r.top())
|
||||
path2.lineTo(r.right(), r.center().y())
|
||||
path2.lineTo(r.center().x(), r.bottom())
|
||||
path2.closeSubpath()
|
||||
p.drawPath(path2)
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_skip_back(color: str = "#aaaaaa") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
p.setPen(Qt.NoPen)
|
||||
p.setBrush(c)
|
||||
path = QPainterPath()
|
||||
path.moveTo(r.right() * 0.7, r.top())
|
||||
path.lineTo(r.left(), r.center().y())
|
||||
path.lineTo(r.right() * 0.7, r.bottom())
|
||||
path.closeSubpath()
|
||||
p.drawPath(path)
|
||||
# Vertical bar
|
||||
bar_w = r.width() * 0.12
|
||||
p.drawRect(QRectF(r.right() - bar_w, r.top(), bar_w, r.height()))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_skip_forward(color: str = "#aaaaaa") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
p.setPen(Qt.NoPen)
|
||||
p.setBrush(c)
|
||||
path = QPainterPath()
|
||||
path.moveTo(r.left() + r.width() * 0.3, r.top())
|
||||
path.lineTo(r.right(), r.center().y())
|
||||
path.lineTo(r.left() + r.width() * 0.3, r.bottom())
|
||||
path.closeSubpath()
|
||||
p.drawPath(path)
|
||||
bar_w = r.width() * 0.12
|
||||
p.drawRect(QRectF(r.left(), r.top(), bar_w, r.height()))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_eject(color: str = "#ff4444") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
pen = QPen(c, r.width() * 0.12)
|
||||
pen.setCapStyle(Qt.RoundCap)
|
||||
p.setPen(pen)
|
||||
p.setBrush(Qt.NoBrush)
|
||||
# Upward triangle
|
||||
mid_x = r.center().x()
|
||||
path = QPainterPath()
|
||||
path.moveTo(r.left() + r.width() * 0.2, r.center().y() + r.height() * 0.1)
|
||||
path.lineTo(mid_x, r.top() + r.height() * 0.2)
|
||||
path.lineTo(r.right() - r.width() * 0.2, r.center().y() + r.height() * 0.1)
|
||||
p.drawPath(path)
|
||||
# Horizontal line
|
||||
p.drawLine(QPointF(r.left() + r.width() * 0.2, r.bottom() - r.height() * 0.1),
|
||||
QPointF(r.right() - r.width() * 0.2, r.bottom() - r.height() * 0.1))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
# ── Action Icons ───────────────────────────────────────────────────
|
||||
|
||||
def icon_plus(color: str = "#00ff41") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
pen = QPen(c, r.width() * 0.12)
|
||||
pen.setCapStyle(Qt.RoundCap)
|
||||
p.setPen(pen)
|
||||
p.setBrush(Qt.NoBrush)
|
||||
mid = r.center()
|
||||
p.drawLine(QPointF(mid.x(), r.top()), QPointF(mid.x(), r.bottom()))
|
||||
p.drawLine(QPointF(r.left(), mid.y()), QPointF(r.right(), mid.y()))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_delete(color: str = "#ff4444") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
pen = QPen(c, r.width() * 0.12)
|
||||
pen.setCapStyle(Qt.RoundCap)
|
||||
p.setPen(pen)
|
||||
p.setBrush(Qt.NoBrush)
|
||||
p.drawLine(QPointF(r.left(), r.top()), QPointF(r.right(), r.bottom()))
|
||||
p.drawLine(QPointF(r.right(), r.top()), QPointF(r.left(), r.bottom()))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_save(color: str = "#aaaaaa") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
pen = QPen(c, r.width() * 0.12)
|
||||
pen.setCapStyle(Qt.RoundCap)
|
||||
p.setPen(pen)
|
||||
p.setBrush(Qt.NoBrush)
|
||||
# Arrow down into tray
|
||||
mid_x = r.center().x()
|
||||
p.drawLine(QPointF(mid_x, r.top()), QPointF(mid_x, r.bottom() - r.height() * 0.15))
|
||||
# Arrow head
|
||||
p.drawLine(QPointF(mid_x - r.width() * 0.25, r.bottom() - r.height() * 0.4),
|
||||
QPointF(mid_x, r.bottom() - r.height() * 0.15))
|
||||
p.drawLine(QPointF(mid_x + r.width() * 0.25, r.bottom() - r.height() * 0.4),
|
||||
QPointF(mid_x, r.bottom() - r.height() * 0.15))
|
||||
# Tray bottom line
|
||||
p.drawLine(QPointF(r.left(), r.bottom()), QPointF(r.right(), r.bottom()))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_load(color: str = "#aaaaaa") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
pen = QPen(c, r.width() * 0.12)
|
||||
pen.setCapStyle(Qt.RoundCap)
|
||||
p.setPen(pen)
|
||||
p.setBrush(Qt.NoBrush)
|
||||
# Arrow up from tray
|
||||
mid_x = r.center().x()
|
||||
p.drawLine(QPointF(mid_x, r.bottom()), QPointF(mid_x, r.top() + r.height() * 0.15))
|
||||
p.drawLine(QPointF(mid_x - r.width() * 0.25, r.top() + r.height() * 0.35),
|
||||
QPointF(mid_x, r.top() + r.height() * 0.1))
|
||||
p.drawLine(QPointF(mid_x + r.width() * 0.25, r.top() + r.height() * 0.35),
|
||||
QPointF(mid_x, r.top() + r.height() * 0.1))
|
||||
p.drawLine(QPointF(r.left(), r.bottom()), QPointF(r.right(), r.bottom()))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_export(color: str = "#aaaaaa") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
pen = QPen(c, r.width() * 0.12)
|
||||
pen.setCapStyle(Qt.RoundCap)
|
||||
p.setPen(pen)
|
||||
p.setBrush(Qt.NoBrush)
|
||||
# Box
|
||||
margin = r.width() * 0.15
|
||||
p.drawRect(r.adjusted(margin, margin, -margin, -margin))
|
||||
# Arrow out of box (top-right)
|
||||
p.drawLine(QPointF(r.right() - margin, r.top() + margin),
|
||||
QPointF(r.right(), r.top()))
|
||||
p.drawLine(QPointF(r.right() - r.width() * 0.3, r.top()),
|
||||
QPointF(r.right(), r.top()))
|
||||
p.drawLine(QPointF(r.right(), r.top() + r.height() * 0.3),
|
||||
QPointF(r.right(), r.top()))
|
||||
return _make_icon(paint, color)
|
||||
|
||||
|
||||
def icon_theme(color: str = "#00ff41") -> QIcon:
|
||||
def paint(p, r, c):
|
||||
p.setPen(Qt.NoPen)
|
||||
# Draw 4 coloured quadrants
|
||||
mid = r.center()
|
||||
colors = [QColor("#00ff41"), QColor("#ffaa00"),
|
||||
QColor("#00aaff"), QColor("#ff4444")]
|
||||
for i, col in enumerate(colors):
|
||||
path = QPainterPath()
|
||||
if i == 0:
|
||||
path.moveTo(mid)
|
||||
path.arcTo(r, 0, 90)
|
||||
path.closeSubpath()
|
||||
elif i == 1:
|
||||
path.moveTo(mid)
|
||||
path.arcTo(r, 270, 90)
|
||||
path.closeSubpath()
|
||||
elif i == 2:
|
||||
path.moveTo(mid)
|
||||
path.arcTo(r, 180, 90)
|
||||
path.closeSubpath()
|
||||
else:
|
||||
path.moveTo(mid)
|
||||
path.arcTo(r, 90, 90)
|
||||
path.closeSubpath()
|
||||
p.setBrush(col)
|
||||
p.drawPath(path)
|
||||
# White circle in centre
|
||||
p.setBrush(QColor("#ffffff"))
|
||||
p.drawEllipse(mid, r.width() * 0.15, r.height() * 0.15)
|
||||
return _make_icon(paint, color)
|
||||
Reference in New Issue
Block a user