SwapStation_Dashboard/ui/styles.py

490 lines
16 KiB
Python

# --- Dynamic Theme Stylesheets ---
def get_light_theme_styles(scale=1.0):
log_font_size = max(10, int(11 * scale))
button_font_size = max(7, int(10 * scale))
big_button_font = int(button_font_size * 13 // 10) # 1.3x as int
return f"""
QMainWindow, QWidget {{
background-color: #f0f0f0;
color: #000;
}}
/* Status Bar */
#StatusBar {{
background-color: #34495e;
padding: {int(6 * scale)}px;
}}
/* Logs */
#LogPanel {{
font-family: "Courier New", Consolas, monospace;
font-size: {log_font_size}pt;
background-color: #ffffff;
color: #2b2b2b;
border: 1px solid #c8c8c8;
}}
/* Containers */
QGroupBox {{
font-family: Arial;
border: 1px solid #c8c8c8;
border-radius: {int(8 * scale)}px;
margin-top: {int(6 * scale)}px;
}}
QGroupBox::title {{
subcontrol-origin: margin;
subcontrol-position: top center;
padding: 0 {int(10 * scale)}px;
color: #000;
}}
/* Tabs */
QTabWidget::pane {{ border-top: 2px solid #c8c8c8; }}
QTabBar::tab {{
background: #e1e1e1; border: 1px solid #c8c8c8;
padding: {int(6 * scale)}px {int(15 * scale)}px;
border-top-left-radius: {int(4 * scale)}px; border-top-right-radius: {int(4 * scale)}px;
}}
QTabBar::tab:selected {{ background: #f0f0f0; border-bottom-color: #f0f0f0; }}
/* Forms */
QFormLayout::label {{ color: #000; padding-top: {int(3 * scale)}px; }}
QLineEdit, QPlainTextEdit, QComboBox {{
background-color: #fff; border: 1px solid #c8c8c8;
border-radius: {int(4 * scale)}px; padding: {int(4 * scale)}px;
font-size: {max(7, int(9 * scale))}pt;
color: #000;
}}
QLineEdit:read-only {{ background-color: #e9e9e9; }}
/* Buttons (generic) */
QPushButton {{
background-color: #e1e1e1; border: 1px solid #c8c8c8;
padding: {int(5 * scale)}px {int(10 * scale)}px;
border-radius: {int(4 * scale)}px;
color: #000;
}}
QPushButton:hover {{ background-color: #dcdcdc; }}
QPushButton:pressed {{ background-color: #c8c8c8; }}
QPushButton:disabled {{ background-color: #d3d3d3; color: #a0a0a0; }}
/* Primary/Destructive (larger) */
#RefreshButton, #ResetButton {{
padding: {int(6 * scale)}px {int(16 * scale)}px;
font-size: {big_button_font}pt;
font-weight: bold;
color: white;
border-radius: {int(4*scale)}px;
}}
#RefreshButton {{ background-color: #2e7d32; }}
#ResetButton {{ background-color: #c62828; }}
/* Action buttons */
#ConnectButton, #DisconnectButton, #StartSwapButton, #AbortSwapButton {{
padding: {int(6 * scale)}px {int(16 * scale)}px;
font-size: {button_font_size}pt;
font-weight: bold;
border-radius: {int(4 * scale)}px;
color: white;
border: none;
}}
#ConnectButton, #StartSwapButton {{ background-color: #28a745; }}
#ConnectButton:hover, #StartSwapButton:hover {{ background-color: #218838; }}
#DisconnectButton, #AbortSwapButton {{ background-color: #dc3545; }}
#DisconnectButton:hover, #AbortSwapButton:hover {{ background-color: #c82333; }}
#ConnectButton:disabled, #DisconnectButton:disabled {{
background-color: #b0bec5; color: #78909c;
}}
/* Unique */
#SendAudioButton {{
background-color: #007bff; color: white; border: none;
font-size: {max(10, int(14 * scale))}px;
}}
#SendAudioButton:hover {{ background-color: #0069d9; }}
#ChamberOpenDoorButton, #ChamberChgOnButton, #ChamberChgOffButton {{
padding: {int(8 * scale)}px;
font-size: {button_font_size}pt;
font-weight: bold;
border-radius: {int(4*scale)}px;
}}
#ChamberOpenDoorButton {{ background-color: #607d8b; }}
#ChamberChgOnButton {{ background-color: #52be80; }}
#ChamberChgOffButton {{ background-color: #cd6155; }}
#ChamberOpenDoorButton:hover {{ background-color: #485c64; }}
#ChamberChgOnButton:hover {{ background-color: #04d45d; }}
#ChamberChgOffButton:hover {{ background-color: #d42318; }}
/* Status & alarms */
QLabel[status="present"] {{ background-color: #2ecc71; color: white; border-radius: {int(4*scale)}px; padding: {int(3*scale)}px; }}
QLabel[status="absent"] {{ background-color: #e74c3c; color: white; border-radius: {int(4*scale)}px; padding: {int(3*scale)}px; }}
QLabel[alarm="active"] {{ background-color: #e74c3c; color: white; font-weight: bold; border-radius: {int(4*scale)}px; padding: {int(2*scale)}px; }}
QLabel[alarm="inactive"] {{ background-color: transparent; color: black; }}
QGroupBox#ChamberWidget {{ border: 2px solid #007bff; }}
/* Timestamp */
QLabel#TimestampTitleLabel {{
font-size: {max(9, int(11 * scale))}pt;
font-weight: bold;
}}
QLineEdit#TimestampDataField {{
font-size: {max(11, int(13 * scale))}pt;
font-weight: bold;
color: #000000;
}}
QGroupBox#ChamberWidget QFormLayout QLabel {{
font-size: {max(10, int(12 * scale))}px;
color: #AAAAAA;
}}
QGroupBox#ChamberWidget QLineEdit#BatIdField {{
font-size: {max(14, int(16 * scale))}px;
font-weight: bold;
color: #000000;
}}
QGroupBox#ChamberWidget QLineEdit#DataField {{
font-size: {max(13, int(14 * scale))}px;
color: #000000;
}}
QGroupBox#ChamberWidget QLineEdit#DoorStatusField {{
font-size: {max(12, int(14 * scale))}px;
font-weight: bold;
color: #000000;
}}
/* ---------- ABOUT CARD (LIGHT) ---------- */
#aboutCard {{
background: #ffffff;
border: 1px solid #dee2e6;
border-radius: 12px;
}}
#aboutCard #title {{
color: #212529;
font-size: {max(16, int(18 * scale))}pt;
font-weight: 700;
letter-spacing: 0.2px;
}}
#aboutCard #subtitle {{
color: #6c757d;
font-size: {max(9, int(11 * scale))}pt;
font-weight: 500;
}}
#aboutCard #kvLabel {{
color: #495057;
font-weight: 600;
}}
#aboutCard #badge {{
color: #0b1220;
background: #e9ecef;
border-radius: 999px;
padding: {int(5*scale)}px {int(12*scale)}px;
font-weight: 700;
letter-spacing: 0.3px;
font-size: {max(8, int(10*scale))}pt;
}}
#aboutCard #divider {{
background: #dee2e6;
min-height: 1px; max-height: 1px; border: none;
margin: {int(6*scale)}px 0 {int(8*scale)}px 0;
}}
#aboutCard #footer {{
color: #7a8794;
font-size: {max(8, int(10*scale))}pt;
}}
#aboutCard a {{
color: #007bff; text-decoration: none;
}}
#aboutCard a:hover {{
text-decoration: underline;
}}
#aboutCard [link="true"] {{
color: #0d6efd; /* Bootstrap dark blue */
text-decoration: none;
}}
#aboutCard [link="true"]:hover {{
color: #0a58ca; /* darker blue on hover */
text-decoration: underline;
}}
/* ---------- HELP CARD (LIGHT) ---------- */
#helpCard {{
background: #ffffff;
border: 1px solid #dee2e6;
border-radius: 12px;
}}
#helpTitle {{
color: #212529;
font-weight: 700;
font-size: 18px;
}}
#helpSubtitle {{
color: #495057;
font-size: 12px;
}}
#helpDivider {{
background: #dee2e6;
min-height: 1px; max-height: 1px; border: none;
}}
#sectionTitle {{
color: #212529;
font-weight: 600;
margin-top: 6px;
}}
#bodyText {{
color: #343a40;
}}
/* Callouts (light theme) */
#tipBox {{
background: #e6ffed;
border: 1px solid #28a745;
border-radius: 8px;
}}
#tipTitle {{ color: #155724; font-weight: 700; }}
#tipText {{ color: #155724; }}
#warnBox {{
background: #fff3cd;
border: 1px solid #ffb74d;
border-radius: 8px;
}}
#warnTitle {{ color: #856404; font-weight: 700; }}
#warnText {{ color: #856404; }}
#link {{
color: #0827F5; /* Current */
text-decoration: none;
}}
#link:hover {{
color: #00008b; /* Hover color */
text-decoration: underline;
}}
"""
def get_dark_theme_styles(scale=1.0):
log_font_size = max(10, int(11 * scale))
button_font_size = max(7, int(10 * scale))
return f"""
QMainWindow, QWidget {{ background-color: #2b2b2b; color: #f0f0f0; }}
#LogPanel {{
font-family: "Courier New", Consolas, monospace;
font-size: {log_font_size}pt;
background-color: #212121;
color: #eceff1;
border: 1px solid #455a64;
}}
QGroupBox {{
font-family: Arial; border: 1px solid #4a4a4a;
border-radius: {int(8 * scale)}px; margin-top: {int(6 * scale)}px;
}}
QGroupBox::title {{ subcontrol-origin: margin; subcontrol-position: top center; padding: 0 {int(10 * scale)}px; color: #f0f0f0; }}
QTabWidget::pane {{ border-top: 2px solid #4a4a4a; }}
QTabBar::tab {{
background: #3c3c3c; border: 1px solid #4a4a4a; color: #f0f0f0;
padding: {int(6 * scale)}px {int(15 * scale)}px;
border-top-left-radius: {int(4 * scale)}px; border-top-right-radius: {int(4 * scale)}px;
}}
QTabBar::tab:selected {{ background: #2b2b2b; border-bottom-color: #2b2b2b; }}
QFormLayout::label {{ color: #f0f0f0; padding-top: {int(3 * scale)}px; }}
QLineEdit, QPlainTextEdit, QComboBox {{
background-color: #3c3c3c; border: 1px solid #4a4a4a;
border-radius: {int(4 * scale)}px; padding: {int(4 * scale)}px; color: #f0f0f0;
font-size: {max(7, int(9 * scale))}pt;
}}
QLineEdit:read-only {{ background-color: #333333; }}
QPushButton {{
background-color: #555555; border: 1px solid #4a4a4a;
padding: {int(5 * scale)}px {int(10 * scale)}px;
border-radius: {int(4 * scale)}px; color: #f0f0f0;
}}
QPushButton:hover {{ background-color: #6a6a6a; }}
QPushButton:pressed {{ background-color: #4a4a4a; }}
QPushButton:disabled {{ background-color: #404040; color: #888888; }}
#RefreshButton, #ResetButton {{
padding: {int(6 * scale)}px {int(16 * scale)}px;
font-size: {int(button_font_size * 1.3)}pt;
font-weight: bold;
border-radius: {int(4*scale)}px;
}}
#RefreshButton {{ background-color: #2e7d32; }}
#ResetButton {{ background-color: #c62828; }}
#ChamberOpenDoorButton, #ChamberChgOnButton, #ChamberChgOffButton {{
padding: {int(8 * scale)}px;
font-size: {button_font_size}pt;
font-weight: bold;
border-radius: {int(4*scale)}px;
}}
#ChamberOpenDoorButton {{ background-color: #607d8b; }}
#ChamberChgOnButton {{ background-color: #52be80; }}
#ChamberChgOffButton {{ background-color: #cd6155; }}
#ChamberOpenDoorButton:hover {{ background-color: #485c64; }}
#ChamberChgOnButton:hover {{ background-color: #04d45d; }}
#ChamberChgOffButton:hover {{ background-color: #d42318; }}
#ConnectButton, #DisconnectButton {{
padding: {int(6 * scale)}px {int(16 * scale)}px;
font-size: {button_font_size}pt;
font-weight: bold;
border-radius: {int(4*scale)}px;
color: white;
}}
#ConnectButton {{ background-color: #27ae60; }}
#DisconnectButton {{ background-color: #c0392b; }}
#ConnectButton:hover {{ background-color: #52be80; }}
#DisconnectButton:hover {{ background-color: #cd6155; }}
#ConnectButton:pressed {{ background-color: #52be80; }}
#DisconnectButton:pressed {{ background-color: #cd6155; }}
#ConnectButton:disabled, #DisconnectButton:disabled {{
background-color: #546e7a; color: #90a4ae;
}}
#RefreshButton, #StartSwapButton {{ background-color: #27ae60; color: white; border: none; }}
#RefreshButton:hover, #StartSwapButton:hover {{ background-color: #52be80; }}
#ResetButton, #AbortSwapButton {{ background-color: #c0392b; color: white; border: none; }}
#ResetButton:hover, #AbortSwapButton:hover {{ background-color: #cd6155; }}
#SendAudioButton {{ background-color: #3498db; color: white; border: none; font-size: {max(10, int(14 * scale))}px; }}
#SendAudioButton:hover {{ background-color: #5dade2; }}
QLabel[status="present"] {{ background-color: #2ecc71; color: white; border-radius: {int(4*scale)}px; padding: {int(3*scale)}px; }}
QLabel[status="absent"] {{ background-color: #e74c3c; color: white; border-radius: {int(4*scale)}px; padding: {int(3*scale)}px; }}
QLabel[alarm="active"] {{ background-color: #e74c3c; color: white; font-weight: bold; border-radius: {int(4*scale)}px; padding: {int(2*scale)}px; }}
QLabel[alarm="inactive"] {{ background-color: transparent; color: #f0f0f0; }}
QGroupBox#ChamberWidget {{ border: 2px solid #3498db; }}
QLabel#TimestampTitleLabel {{
font-size: {max(9, int(11 * scale))}pt;
font-weight: bold;
}}
QLineEdit#TimestampDataField {{
font-size: {max(11, int(13 * scale))}pt;
font-weight: bold;
color: #f0f0f0;
}}
QGroupBox#ChamberWidget QFormLayout QLabel {{
font-size: {max(10, int(12 * scale))}px;
color: #AAAAAA;
}}
QGroupBox#ChamberWidget QLineEdit#BatIdField {{
font-size: {max(14, int(16 * scale))}px;
font-weight: bold;
color: #FFFFFF;
}}
QGroupBox#ChamberWidget QLineEdit#DataField {{
font-size: {max(13, int(14 * scale))}px;
color: #E0E0E0;
}}
QGroupBox#ChamberWidget QLineEdit#DoorStatusField {{
font-size: {max(12, int(14 * scale))}px;
font-weight: bold;
color: #E0E0E0;
}}
/* ---------- ABOUT CARD (DARK) ---------- */
#aboutCard {{
background: #2a2a2a;
border: 1px solid #3a3a3a;
border-radius: 12px;
}}
#aboutCard #title {{
color: #eaeaea;
font-size: {max(16, int(18 * scale))}pt;
font-weight: 700;
letter-spacing: 0.2px;
}}
#aboutCard #subtitle {{
color: #aab4c0;
font-size: {max(9, int(11 * scale))}pt;
font-weight: 500;
}}
#aboutCard #kvLabel {{
color: #b6b6b6;
font-weight: 600;
}}
#aboutCard #badge {{
color: #eaf3ff;
background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #2563eb, stop:1 #7c3aed);
border-radius: 999px;
padding: {int(5*scale)}px {int(12*scale)}px;
font-weight: 700;
letter-spacing: 0.3px;
font-size: {max(8, int(10*scale))}pt;
text-transform: uppercase;
}}
#aboutCard #divider {{
background: #3a3a3a;
margin: {int(6*scale)}px 0 {int(8*scale)}px 0;
min-height: 1px;
max-height: 1px;
border: none;
}}
#aboutCard #footer {{
color: #7e8895;
font-size: {max(8, int(10*scale))}pt;
}}
#aboutCard a {{
color: #6aa9ff; text-decoration: none;
}}
#aboutCard a:hover {{ color: #82b1ff; text-decoration: underline; }}
/* ---------- HELP CARD (DARK) ---------- */
#helpCard {{
background: #2a2a2a;
border: 1px solid #3a3a3a;
border-radius: 12px;
}}
#helpTitle {{ color: #eaeaea; font-weight: 700; font-size: 18px; }}
#helpSubtitle {{ color: #c8c8c8; font-size: 12px; }}
#helpDivider {{ background: #3a3a3a; min-height: 1px; max-height: 1px; border: none; }}
#sectionTitle {{ color: #e6e6e6; font-weight: 600; margin-top: 6px; }}
#bodyText {{ color: #dcdcdc; }}
/* Callouts (dark theme) */
#tipBox {{
background: #1f3326;
border: 1px solid #62d39b;
border-radius: 8px;
}}
#tipTitle {{ color: #a8f5c9; font-weight: 700; }}
#tipText {{ color: #d6ffe9; }}
#warnBox {{
background: #3b2e1b;
border: 1px solid #ffb74d;
border-radius: 8px;
}}
#warnTitle {{ color: #ffd561; font-weight: 700; }}
#warnText {{ color: #f0e0c0; }}
#link {{
color: #007bff; /* Standard Bootstrap blue */
text-decoration: none;
}}
#link:hover {{
color: #0056b3; /* Darker blue on hover */
text-decoration: underline;
}}
"""