Spaces:
Running
Running
File size: 4,414 Bytes
b9460ef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | 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) |