trainlog-egu5j / ui /theme.py
kuubson's picture
🐳 09/03 - 18:26 - Stwórz kompletną aplikację do odtwarzania playlist M3U / M3U8 napisaną w Pythonie, z nowoczesnym, przejrzystym i premium UI, wizualnie inspirowanym stylem IBO Pro Player. Aplikacja
b9460ef verified
from PySide6.QtCore import QSize
from PySide6.QtGui import QColor, QFont, QPalette
from PySide6.QtWidgets import QApplication
class ModernTheme:
DARK_BG = "#0f0f0f"
DARK_SURFACE = "#1a1a1a"
DARK_ELEVATION = "#242424"
DARK_BORDER = "#2a2a2a"
ACCENT_PRIMARY = "#6366f1"
ACCENT_SECONDARY = "#8b5cf6"
ACCENT_HOVER = "#818cf8"
TEXT_PRIMARY = "#ffffff"
TEXT_SECONDARY = "#a1a1aa"
TEXT_DISABLED = "#71717a"
SUCCESS = "#22c55e"
WARNING = "#f59e0b"
ERROR = "#ef4444"
GRADIENT_HEADER = "linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%)"
@staticmethod
def get_stylesheet():
return f"""
QMainWindow, QWidget {{
background-color: {ModernTheme.DARK_BG};
color: {ModernTheme.TEXT_PRIMARY};
font-family: 'Segoe UI', 'SF Pro Display', -apple-system, sans-serif;
}}
QScrollBar:vertical {{
background: {ModernTheme.DARK_SURFACE};
width: 8px;
border-radius: 4px;
}}
QScrollBar::handle:vertical {{
background: {ModernTheme.TEXT_DISABLED};
border-radius: 4px;
min-height: 30px;
}}
QScrollBar::handle:vertical:hover {{
background: {ModernTheme.TEXT_SECONDARY};
}}
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {{
height: 0px;
}}
QLineEdit {{
background-color: {ModernTheme.DARK_ELEVATION};
border: 1px solid {ModernTheme.DARK_BORDER};
border-radius: 8px;
padding: 10px 14px;
color: {ModernTheme.TEXT_PRIMARY};
font-size: 14px;
}}
QLineEdit:focus {{
border: 1px solid {ModernTheme.ACCENT_PRIMARY};
}}
QPushButton {{
background-color: {ModernTheme.ACCENT_PRIMARY};
color: white;
border: none;
border-radius: 8px;
padding: 10px 20px;
font-weight: 600;
font-size: 14px;
}}
QPushButton:hover {{
background-color: {ModernTheme.ACCENT_HOVER};
}}
QPushButton:pressed {{
background-color: {ModernTheme.ACCENT_PRIMARY};
}}
QPushButton#secondary {{
background-color: {ModernTheme.DARK_ELEVATION};
border: 1px solid {ModernTheme.DARK_BORDER};
color: {ModernTheme.TEXT_PRIMARY};
}}
QPushButton#secondary:hover {{
background-color: {ModernTheme.DARK_SURFACE};
border-color: {ModernTheme.ACCENT_PRIMARY};
}}
QLabel {{
color: {ModernTheme.TEXT_PRIMARY};
}}
QLabel#title {{
font-size: 24px;
font-weight: 700;
margin-bottom: 8px;
}}
QLabel#subtitle {{
font-size: 14px;
color: {ModernTheme.TEXT_SECONDARY};
}}
QListWidget {{
background-color: {ModernTheme.DARK_SURFACE};
border: 1px solid {ModernTheme.DARK_BORDER};
border-radius: 12px;
outline: none;
padding: 8px;
}}
QListWidget::item {{
border-radius: 8px;
padding: 12px;
margin: 4px;
}}
QListWidget::item:selected {{
background-color: {ModernTheme.ACCENT_PRIMARY};
color: white;
}}
QListWidget::item:hover {{
background-color: {ModernTheme.DARK_ELEVATION};
}}
QFrame#card {{
background-color: {ModernTheme.DARK_SURFACE};
border-radius: 16px;
border: 1px solid {ModernTheme.DARK_BORDER};
}}
QFrame#card:hover {{
border-color: {ModernTheme.ACCENT_PRIMARY};
}}
"""
@staticmethod
def apply_theme(app: QApplication):
app.setStyleSheet(ModernTheme.get_stylesheet())
font = QFont("Segoe UI", 10)
if not QFont(font).exactMatch():
font = QFont("SF Pro Display", 10)
if not QFont(font).exactMatch():
font = QFont("Arial", 10)
app.setFont(font)