Files
yolocam-linux/yolocam-gui/yolocam_gui/ui/theme.py
T
2026-02-15 12:50:49 -08:00

237 lines
6.6 KiB
Python

# Copyright (C) 2026 Seth Hillbrand
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""Dark theme stylesheet for YoloCam."""
# Palette constants used throughout the application
COLOR_BG_DARK = "#181818"
COLOR_BG_PANEL = "#242424"
COLOR_BG_SECTION_HEADER = "#2d2d2d"
COLOR_BG_INPUT = "#333333"
COLOR_BG_SIDEBAR = "#1e1e1e"
COLOR_ACCENT = "#e91e63"
COLOR_ACCENT_LIGHT = "#ff5252"
COLOR_SLIDER_EMPTY = "#444444"
COLOR_TOGGLE_OFF = "#555555"
COLOR_TEXT_PRIMARY = "#ffffff"
COLOR_TEXT_SECONDARY = "#aaaaaa"
COLOR_BORDER = "#3a3a3a"
def build_stylesheet() -> str:
return f"""
/* Global defaults */
QWidget {{
background-color: {COLOR_BG_DARK};
color: {COLOR_TEXT_PRIMARY};
font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
font-size: 13px;
}}
/* Main window */
QMainWindow {{
background-color: {COLOR_BG_DARK};
}}
/* Scroll area used for the parameter panel */
QScrollArea {{
border: none;
background-color: {COLOR_BG_PANEL};
}}
QScrollArea > QWidget > QWidget {{
background-color: {COLOR_BG_PANEL};
}}
QScrollBar:vertical {{
background: {COLOR_BG_PANEL};
width: 8px;
margin: 0;
}}
QScrollBar::handle:vertical {{
background: {COLOR_SLIDER_EMPTY};
min-height: 30px;
border-radius: 4px;
}}
QScrollBar::handle:vertical:hover {{
background: {COLOR_TEXT_SECONDARY};
}}
QScrollBar::add-line:vertical,
QScrollBar::sub-line:vertical {{
height: 0;
}}
QScrollBar:horizontal {{
height: 0;
}}
/* Labels */
QLabel {{
background: transparent;
color: {COLOR_TEXT_PRIMARY};
padding: 0;
}}
/* ComboBox / dropdown */
QComboBox {{
background-color: {COLOR_BG_INPUT};
color: {COLOR_TEXT_PRIMARY};
border: 1px solid {COLOR_BORDER};
border-radius: 4px;
padding: 4px 8px;
min-height: 24px;
}}
QComboBox:hover {{
border-color: {COLOR_ACCENT};
}}
QComboBox::drop-down {{
border: none;
width: 20px;
}}
QComboBox::down-arrow {{
image: none;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 5px solid {COLOR_TEXT_SECONDARY};
margin-right: 6px;
}}
QComboBox QAbstractItemView {{
background-color: {COLOR_BG_INPUT};
color: {COLOR_TEXT_PRIMARY};
border: 1px solid {COLOR_BORDER};
selection-background-color: {COLOR_ACCENT};
selection-color: {COLOR_TEXT_PRIMARY};
}}
/* SpinBox */
QSpinBox, QDoubleSpinBox {{
background-color: {COLOR_BG_INPUT};
color: {COLOR_TEXT_PRIMARY};
border: 1px solid {COLOR_BORDER};
border-radius: 4px;
padding: 2px 4px;
min-height: 22px;
}}
QSpinBox::up-button, QDoubleSpinBox::up-button {{
subcontrol-origin: border;
subcontrol-position: top right;
width: 16px;
border-left: 1px solid {COLOR_BORDER};
background: {COLOR_BG_SECTION_HEADER};
}}
QSpinBox::down-button, QDoubleSpinBox::down-button {{
subcontrol-origin: border;
subcontrol-position: bottom right;
width: 16px;
border-left: 1px solid {COLOR_BORDER};
background: {COLOR_BG_SECTION_HEADER};
}}
QSpinBox::up-arrow, QDoubleSpinBox::up-arrow {{
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-bottom: 4px solid {COLOR_TEXT_SECONDARY};
width: 0; height: 0;
}}
QSpinBox::down-arrow, QDoubleSpinBox::down-arrow {{
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 4px solid {COLOR_TEXT_SECONDARY};
width: 0; height: 0;
}}
/* Push buttons */
QPushButton {{
background-color: {COLOR_BG_INPUT};
color: {COLOR_TEXT_PRIMARY};
border: 1px solid {COLOR_BORDER};
border-radius: 4px;
padding: 5px 12px;
min-height: 24px;
}}
QPushButton:hover {{
background-color: {COLOR_SLIDER_EMPTY};
}}
QPushButton:pressed {{
background-color: {COLOR_BG_SECTION_HEADER};
}}
QPushButton[accent="true"] {{
background-color: {COLOR_ACCENT};
border: none;
font-weight: bold;
}}
QPushButton[accent="true"]:hover {{
background-color: #f02574;
}}
/* Tool buttons (sidebar icons) */
QToolButton {{
background: transparent;
border: none;
padding: 8px;
border-radius: 4px;
color: {COLOR_TEXT_SECONDARY};
}}
QToolButton:hover {{
background-color: {COLOR_BG_INPUT};
color: {COLOR_TEXT_PRIMARY};
}}
QToolButton:checked {{
background-color: {COLOR_BG_INPUT};
color: {COLOR_ACCENT};
}}
/* Slider (default Qt slider, overridden by ParamSlider painting) */
QSlider::groove:horizontal {{
background: {COLOR_SLIDER_EMPTY};
height: 4px;
border-radius: 2px;
}}
QSlider::handle:horizontal {{
background: {COLOR_TEXT_PRIMARY};
width: 14px;
height: 14px;
margin: -5px 0;
border-radius: 7px;
}}
QSlider::sub-page:horizontal {{
background: qlineargradient(
x1:0, y1:0, x2:1, y2:0,
stop:0 {COLOR_ACCENT}, stop:1 {COLOR_ACCENT_LIGHT}
);
border-radius: 2px;
}}
/* Menu bar */
QMenuBar {{
background-color: {COLOR_BG_SIDEBAR};
color: {COLOR_TEXT_PRIMARY};
border-bottom: 1px solid {COLOR_BORDER};
}}
QMenuBar::item:selected {{
background-color: {COLOR_BG_INPUT};
}}
QMenu {{
background-color: {COLOR_BG_INPUT};
color: {COLOR_TEXT_PRIMARY};
border: 1px solid {COLOR_BORDER};
}}
QMenu::item:selected {{
background-color: {COLOR_ACCENT};
}}
/* Frame separators */
QFrame[frameShape="4"] {{
color: {COLOR_BORDER};
max-height: 1px;
}}
"""