Files
radar_system/python_app/gui/theme.py
T
2026-10-06 14:16:14 +03:00

110 lines
2.9 KiB
Python

"""Application-wide Qt palette and stylesheet configuration."""
from __future__ import annotations
from PyQt6.QtGui import QColor, QPalette
from PyQt6.QtWidgets import QApplication, QStyleFactory
PLOT_BACKGROUND = "#0f141c"
_LIGHT_STYLESHEET = """
QGroupBox {
background-color: #ffffff;
border: 1px solid #d7dee8;
border-radius: 6px;
margin-top: 12px;
padding: 6px;
}
QGroupBox::title {
subcontrol-origin: margin;
left: 10px;
padding: 0 6px;
color: #526277;
font-weight: 600;
}
QPushButton {
background-color: #f8fafc;
border: 1px solid #cad4e1;
border-radius: 4px;
padding: 3px 10px;
}
QPushButton:hover:enabled {
background-color: #eef3f9;
}
QPushButton:pressed {
background-color: #e4ebf4;
}
QPushButton:checked, QPushButton[role="primary"] {
background-color: #2f7ee6;
border-color: #2f7ee6;
color: #ffffff;
}
QPushButton:checked:hover:enabled, QPushButton[role="primary"]:hover:enabled {
background-color: #3b8bf4;
}
QPushButton[role="destructive"] {
color: #a73545;
border-color: #cf9ba4;
}
QPushButton:disabled {
color: #98a4b3;
background-color: #f3f5f8;
border-color: #dde4ec;
}
QTextEdit#runtimeLogBox {
font-family: "DejaVu Sans Mono";
font-size: 12px;
}
QScrollArea {
border: none;
background: transparent;
}
QLabel#statusLabel {
color: #35507a;
font-weight: 600;
}
QLabel#hintLabel {
color: #6c7b8d;
}
"""
def apply_light_theme(app: QApplication) -> None:
"""Apply a minimal light theme shared by all windows."""
app.setStyle(QStyleFactory.create("Fusion"))
font = app.font()
font.setPointSize(10)
app.setFont(font)
palette = QPalette()
palette.setColor(QPalette.ColorRole.Window, QColor("#f3f6fb"))
palette.setColor(QPalette.ColorRole.WindowText, QColor("#1f2937"))
palette.setColor(QPalette.ColorRole.Base, QColor("#ffffff"))
palette.setColor(QPalette.ColorRole.AlternateBase, QColor("#eef3f8"))
palette.setColor(QPalette.ColorRole.ToolTipBase, QColor("#ffffff"))
palette.setColor(QPalette.ColorRole.ToolTipText, QColor("#1f2937"))
palette.setColor(QPalette.ColorRole.Text, QColor("#1f2937"))
palette.setColor(QPalette.ColorRole.Button, QColor("#f8fafc"))
palette.setColor(QPalette.ColorRole.ButtonText, QColor("#1f2937"))
palette.setColor(QPalette.ColorRole.BrightText, QColor("#ffffff"))
palette.setColor(QPalette.ColorRole.Link, QColor("#2f7ee6"))
palette.setColor(QPalette.ColorRole.Highlight, QColor("#2f7ee6"))
palette.setColor(QPalette.ColorRole.HighlightedText, QColor("#ffffff"))
for role in (QPalette.ColorRole.Text, QPalette.ColorRole.ButtonText, QPalette.ColorRole.WindowText):
palette.setColor(QPalette.ColorGroup.Disabled, role, QColor("#98a4b3"))
palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Base, QColor("#f3f5f8"))
app.setPalette(palette)
app.setStyleSheet(_LIGHT_STYLESHEET)