217 lines
5.9 KiB
Python
217 lines
5.9 KiB
Python
from enum import Enum, auto
|
|
from typing import Dict
|
|
|
|
class Colors:
|
|
DARK = {
|
|
'background': '#1E1E1E',
|
|
'surface': '#252526',
|
|
'primary': '#007ACC',
|
|
'secondary': '#3C3C3C',
|
|
'text': '#FFFFFF',
|
|
'text_secondary': '#CCCCCC',
|
|
'border': '#3C3C3C',
|
|
'hover': '#2A2D2E',
|
|
'active': '#37373D',
|
|
'error': '#F44336',
|
|
'success': '#4CAF50',
|
|
'warning': '#FFC107'
|
|
}
|
|
|
|
LIGHT = {
|
|
'background': '#FFFFFF',
|
|
'surface': '#F3F3F3',
|
|
'primary': '#007ACC',
|
|
'secondary': '#E0E0E0',
|
|
'text': '#000000',
|
|
'text_secondary': '#666666',
|
|
'border': '#CCCCCC',
|
|
'hover': '#E8E8E8',
|
|
'active': '#DADADA',
|
|
'error': '#F44336',
|
|
'success': '#4CAF50',
|
|
'warning': '#FFC107'
|
|
}
|
|
|
|
class Fonts:
|
|
FAMILY = "Inter"
|
|
SIZES = {
|
|
"xs": "11px",
|
|
"sm": "13px",
|
|
"md": "14px",
|
|
"lg": "16px",
|
|
"xl": "18px"
|
|
}
|
|
WEIGHTS = {
|
|
"normal": "400",
|
|
"medium": "500",
|
|
"semibold": "600",
|
|
"bold": "700"
|
|
}
|
|
|
|
class Spacing:
|
|
TINY = 4
|
|
SMALL = 8
|
|
MEDIUM = 16
|
|
LARGE = 24
|
|
XLARGE = 32
|
|
XXLARGE = 48
|
|
|
|
class Shadows:
|
|
SMALL = {
|
|
"dark": "0 2px 4px rgba(0, 0, 0, 0.3)",
|
|
"light": "0 2px 4px rgba(0, 0, 0, 0.1)"
|
|
}
|
|
MEDIUM = {
|
|
"dark": "0 4px 8px rgba(0, 0, 0, 0.4)",
|
|
"light": "0 4px 8px rgba(0, 0, 0, 0.15)"
|
|
}
|
|
LARGE = {
|
|
"dark": "0 8px 16px rgba(0, 0, 0, 0.5)",
|
|
"light": "0 8px 16px rgba(0, 0, 0, 0.2)"
|
|
}
|
|
|
|
class Theme(Enum):
|
|
DARK = auto()
|
|
LIGHT = auto()
|
|
|
|
def get_colors(self):
|
|
if self == Theme.DARK:
|
|
return Colors.DARK
|
|
return Colors.LIGHT
|
|
|
|
def get_spacing(self):
|
|
return Spacing
|
|
|
|
def get_fonts(self):
|
|
return Fonts
|
|
|
|
def get_shadows(self):
|
|
if self == Theme.DARK:
|
|
return {k: v["dark"] for k, v in Shadows.__dict__.items() if isinstance(v, dict)}
|
|
return {k: v["light"] for k, v in Shadows.__dict__.items() if isinstance(v, dict)}
|
|
|
|
class StyleSheet:
|
|
@staticmethod
|
|
def get_base_styles(theme: Theme) -> str:
|
|
colors = theme.get_colors()
|
|
spacing = theme.get_spacing()
|
|
|
|
return f"""
|
|
QMainWindow {{
|
|
background-color: {colors['background']};
|
|
}}
|
|
|
|
QWidget {{
|
|
color: {colors['text']};
|
|
font-family: 'Inter';
|
|
}}
|
|
|
|
QPushButton {{
|
|
background-color: {colors['primary']};
|
|
border: none;
|
|
border-radius: {spacing.TINY}px;
|
|
padding: {spacing.SMALL}px {spacing.MEDIUM}px;
|
|
color: white;
|
|
}}
|
|
|
|
QPushButton:hover {{
|
|
background-color: {colors['hover']};
|
|
}}
|
|
|
|
QPushButton:pressed {{
|
|
background-color: {colors['active']};
|
|
}}
|
|
|
|
QLineEdit, QTextEdit {{
|
|
background-color: {colors['surface']};
|
|
border: 1px solid {colors['border']};
|
|
border-radius: {spacing.TINY}px;
|
|
padding: {spacing.SMALL}px;
|
|
color: {colors['text']};
|
|
}}
|
|
|
|
QLineEdit:focus, QTextEdit:focus {{
|
|
border: 1px solid {colors['primary']};
|
|
}}
|
|
|
|
QComboBox {{
|
|
background-color: {colors['surface']};
|
|
border: 1px solid {colors['border']};
|
|
border-radius: {spacing.TINY}px;
|
|
padding: {spacing.SMALL}px;
|
|
color: {colors['text']};
|
|
}}
|
|
|
|
QComboBox:hover {{
|
|
border: 1px solid {colors['primary']};
|
|
}}
|
|
|
|
QLabel {{
|
|
color: {colors['text']};
|
|
}}
|
|
|
|
QScrollBar:vertical {{
|
|
border: none;
|
|
background-color: {colors['surface']};
|
|
width: 10px;
|
|
margin: 0px;
|
|
}}
|
|
|
|
QScrollBar::handle:vertical {{
|
|
background-color: {colors['secondary']};
|
|
min-height: 20px;
|
|
border-radius: 5px;
|
|
}}
|
|
|
|
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {{
|
|
height: 0px;
|
|
}}
|
|
|
|
QScrollBar:horizontal {{
|
|
border: none;
|
|
background-color: {colors['surface']};
|
|
height: 10px;
|
|
margin: 0px;
|
|
}}
|
|
|
|
QScrollBar::handle:horizontal {{
|
|
background-color: {colors['secondary']};
|
|
min-width: 20px;
|
|
border-radius: 5px;
|
|
}}
|
|
|
|
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {{
|
|
width: 0px;
|
|
}}
|
|
"""
|
|
|
|
@staticmethod
|
|
def get_custom_styles(theme: Theme) -> Dict[str, str]:
|
|
colors = theme.get_colors()
|
|
return {
|
|
"primary_button": f"""
|
|
QPushButton {{
|
|
background-color: {colors['primary']};
|
|
color: white;
|
|
}}
|
|
""",
|
|
"secondary_button": f"""
|
|
QPushButton {{
|
|
background-color: transparent;
|
|
color: {colors['primary']};
|
|
border: 1px solid {colors['primary']};
|
|
}}
|
|
""",
|
|
"danger_button": f"""
|
|
QPushButton {{
|
|
background-color: {colors['error']};
|
|
color: white;
|
|
}}
|
|
""",
|
|
"success_button": f"""
|
|
QPushButton {{
|
|
background-color: {colors['success']};
|
|
color: white;
|
|
}}
|
|
"""
|
|
} |