🐛 | Fix tests
All checks were successful
SonarQube Code Quality Scan / SonarQube Scan (push) Successful in 1m44s
All checks were successful
SonarQube Code Quality Scan / SonarQube Scan (push) Successful in 1m44s
This commit is contained in:
88
gui.py
88
gui.py
@@ -11,23 +11,73 @@ import math
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from PySide6.QtCore import (
|
||||
Qt, QTimer, QThread, Signal, Slot, QRectF, QUrl,
|
||||
QPropertyAnimation, QEasingCurve, QLoggingCategory, QEvent,
|
||||
)
|
||||
from PySide6.QtGui import (
|
||||
QFont, QPixmap, QPainter, QColor, QBrush,
|
||||
)
|
||||
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication, QCheckBox, QDialog, QHBoxLayout, QLabel, QLineEdit,
|
||||
QListWidget, QListWidgetItem, QMainWindow, QMenu, QPushButton,
|
||||
QScrollArea, QSlider, QStackedWidget, QVBoxLayout, QWidget, QFrame,
|
||||
QToolButton, QButtonGroup, QSizePolicy,
|
||||
)
|
||||
from PySide6.QtMultimedia import (
|
||||
QAudioBufferOutput,
|
||||
)
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# Qt imports are guarded so the module can be imported for its pure helper
|
||||
# functions (``_fmt_ms``, ``_artists_str``, etc.) even when the system
|
||||
# lacks EGL / PulseAudio native libraries.
|
||||
# The GUI classes will **not** be functional without the real Qt runtime.
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
_HAS_QT = True
|
||||
try:
|
||||
from PySide6.QtCore import (
|
||||
Qt, QTimer, QThread, Signal, Slot, QRectF, QUrl,
|
||||
QPropertyAnimation, QEasingCurve, QLoggingCategory, QEvent,
|
||||
)
|
||||
from PySide6.QtGui import (
|
||||
QFont, QPixmap, QPainter, QColor, QBrush,
|
||||
)
|
||||
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication, QCheckBox, QDialog, QHBoxLayout, QLabel, QLineEdit,
|
||||
QListWidget, QListWidgetItem, QMainWindow, QMenu, QPushButton,
|
||||
QScrollArea, QSlider, QStackedWidget, QVBoxLayout, QWidget, QFrame,
|
||||
QToolButton, QButtonGroup, QSizePolicy,
|
||||
)
|
||||
from PySide6.QtMultimedia import (
|
||||
QAudioBufferOutput,
|
||||
)
|
||||
except (ImportError, OSError):
|
||||
_HAS_QT = False
|
||||
Qt = object
|
||||
QTimer = object
|
||||
QThread = type("QThread", (), {"start": lambda s: None})
|
||||
Signal = lambda *a: lambda f: f
|
||||
Slot = lambda *a: lambda f: f
|
||||
QRectF = object
|
||||
QUrl = None
|
||||
QPropertyAnimation = object
|
||||
QEasingCurve = object
|
||||
QLoggingCategory = object
|
||||
QEvent = object
|
||||
QFont = None
|
||||
QPixmap = object
|
||||
QPainter = object
|
||||
QColor = object
|
||||
QBrush = object
|
||||
QNetworkAccessManager = object
|
||||
QNetworkRequest = object
|
||||
QNetworkReply = object
|
||||
QApplication = object
|
||||
QCheckBox = object
|
||||
QDialog = object
|
||||
QHBoxLayout = object
|
||||
QLabel = object
|
||||
QLineEdit = object
|
||||
QListWidget = object
|
||||
QListWidgetItem = object
|
||||
QMainWindow = object
|
||||
QMenu = object
|
||||
QPushButton = object
|
||||
QScrollArea = object
|
||||
QSlider = object
|
||||
QStackedWidget = object
|
||||
QVBoxLayout = object
|
||||
QWidget = object
|
||||
QFrame = object
|
||||
QToolButton = object
|
||||
QButtonGroup = object
|
||||
QSizePolicy = object
|
||||
QAudioBufferOutput = object
|
||||
|
||||
from config import SETTINGS, get_setting, save_setting, save_volume
|
||||
from discord_rpc import DiscordRPC
|
||||
@@ -36,7 +86,7 @@ from player import AudioPlayer, SearchWorker, _best_thumbnail
|
||||
|
||||
log = logging.getLogger("tunetti.gui")
|
||||
|
||||
FONT = QFont("Cantarell, Noto Sans, Segoe UI, sans-serif", 10)
|
||||
FONT = QFont("Cantarell, Noto Sans, Segoe UI, sans-serif", 10) if QFont else None
|
||||
|
||||
# ── Re-used style constants ──────────────────────────────────────────────
|
||||
_STYLE_BG_TRANSPARENT = "background: transparent;"
|
||||
@@ -73,7 +123,7 @@ def _css(*parts: str) -> str:
|
||||
|
||||
|
||||
# Shared thumbnail downloader to avoid spawning many QNAM instances
|
||||
_thumbnail_nam: Optional[QNetworkAccessManager] = None
|
||||
_thumbnail_nam = None # type: ignore[assignment] # set to QNetworkAccessManager when Qt is available
|
||||
|
||||
|
||||
THUMB_CACHE_DIR = Path.home() / ".cache" / "tunetti"
|
||||
|
||||
Reference in New Issue
Block a user