Initial commit

This commit is contained in:
2026-10-09 02:48:24 +02:00
commit e05d973a8d
133 changed files with 101507 additions and 0 deletions

53
app/spinner.py Normal file
View File

@@ -0,0 +1,53 @@
"""Small activity spinner: a rotating accent-coloured arc. Runs only while visible."""
from PySide6.QtCore import QRectF, QTimer, Qt
from PySide6.QtGui import QColor, QPainter, QPen
from PySide6.QtWidgets import QWidget
from . import icons
STEP_MS = 16
STEP_DEG = 9
def paint_arc(p, rect, angle, color=icons.ACCENT):
"""Draw the spinner (faint ring + 100 degree arc) into rect; used by Spinner and the waveform overlay."""
w = max(1.5, rect.width() / 8)
r = rect.adjusted(w / 2, w / 2, -w / 2, -w / 2)
p.save()
p.setRenderHint(QPainter.RenderHint.Antialiasing)
ring = QColor(color)
ring.setAlpha(45)
p.setPen(QPen(ring, w))
p.drawEllipse(r)
pen = QPen(QColor(color), w)
pen.setCapStyle(Qt.PenCapStyle.RoundCap)
p.setPen(pen)
p.drawArc(r, int(-angle * 16), 100 * 16)
p.restore()
class Spinner(QWidget):
def __init__(self, size=16, parent=None):
super().__init__(parent)
self.setFixedSize(size, size)
self.angle = 0
self.timer = QTimer(self)
self.timer.setInterval(STEP_MS)
self.timer.timeout.connect(self._step)
self.hide()
def _step(self):
self.angle = (self.angle + STEP_DEG) % 360
self.update()
def showEvent(self, e):
self.timer.start()
super().showEvent(e)
def hideEvent(self, e):
self.timer.stop()
super().hideEvent(e)
def paintEvent(self, _):
p = QPainter(self)
paint_arc(p, QRectF(self.rect()), self.angle)