style: переработан стиль всего приложения

This commit is contained in:
Andrew 2024-12-24 11:46:00 +03:00
parent 9ef0c8d34f
commit 8179a33964
10 changed files with 468 additions and 305 deletions

View File

@ -113,7 +113,7 @@ class MainWindow(BaseMainWindow):
system_settings.setIcon(QIcon('resources/system_ico.png'))
system_settings.triggered.connect(lambda: self._toggle_visibility(self.system_dock))
operator_settings = QtWidgets.QAction("Operator settings", self)
operator_settings = QtWidgets.QAction("Operator settings ", self)
operator_settings.setIcon(QIcon('resources/operator_ico.png'))
operator_settings.triggered.connect(lambda: self._toggle_visibility(self.operator_dock))

View File

@ -1,262 +0,0 @@
white_style = """
QMainWindow {
background-color: #ffffff;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
QMessageBox {
background-color: #ffffff;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
QPushButton {
background-color: #d3d3d3;
color: #000000;
padding: 10px 20px;
border: none;
border-radius: 4px;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
QPushButton:hover:!disabled {
background-color: #b0b0b0;
}
QPushButton:disabled {
background-color: #a9a9a9;
color: #7f7f7f;
}
QCheckBox {
color: #000000;
font-size: 14px;
font-family: "Segoe UI", sans-serif;
}
QLineEdit {
background-color: #f0f0f0;
color: #000000;
padding: 5px;
border: 1px solid #a9a9a9;
border-radius: 4px;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
QLabel {
color: #000000;
font-size: 16px;
font-family: "Segoe UI", sans-serif;
}
QGroupBox {
color: #000000;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
QRadioButton {
color: #000000;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
"""
dark_style = """
QWidget {
background-color: #0D1117; /* Тёмный, современный цвет для фона */
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
QMessageBox {
background-color: #161B22;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
QPushButton {
background-color: #FFCC00; /* Яркий жёлтый цвет для акцента */
color: #0D1117; /* Темный цвет текста для контраста с желтым */
padding: 12px 25px;
border: 2px solid #E6B800;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
QPushButton:hover:!disabled {
background-color: #FFD700; /* Светлый желтый цвет для эффекта наведения */
}
QPushButton:disabled {
background-color: #555555;
color: #cccccc;
border: none;
}
QCheckBox {
color: #ffffff;
font-size: 14px;
font-family: "Segoe UI", sans-serif;
font-weight: bold;
}
QLineEdit {
background-color: #21262D;
color: #ffffff;
padding: 8px;
border: 2px solid #30363D;
border-radius: 6px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
QLabel {
color: #ffffff;
font-size: 16px;
font-weight: bold;
font-family: "Segoe UI", sans-serif;
}
QGroupBox {
color: #ffffff;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
border: 1px solid #30363D;
border-radius: 6px;
margin-top: 10px;
}
QRadioButton {
color: #ffffff;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
QSpinBox {
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
QDoubleSpinBox {
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
"""
dis_robots = """
QPushButton {
background-color: #555555;
color: #cccccc;
padding: 12px 25px;
border: none;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
}
QWidget#robot {
border: none;
padding: 5px;
background-color: rgba(33, 33, 33, 100);
}
"""
selected_robot = """
QWidget#robot {
border: 2px solid #E6B800;
border-radius: 10px;
padding: 5px;
}
"""
en_button = """
QPushButton {
background-color: #FFCC00;
color: #0D1117;
padding: 12px 25px;
border: 2px solid #E6B800;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
QPushButton:hover:!disabled {
background-color: #FFD700;
}
"""
dis_button = """
QPushButton {
background-color: #555555;
color: #cccccc;
padding: 12px 25px;
border: none;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
}
"""
saved_button = """
QPushButton {
background-color: #28a745;
color: #ffffff;
padding: 12px 25px;
border: none;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
"""
start_button = """
QPushButton {
background-color: #FFCC00;
color: #0D1117;
padding: 20px 40px;
border: 2px solid #E6B800;
border-radius: 10px;
font-family: "Segoe UI", sans-serif;
font-size: 24px;
font-weight: bold;
background-image: linear-gradient(to bottom, #FFD700, #FFCC00);
}
QPushButton:hover:!disabled {
background-color: #FFD700;
}
QPushButton:pressed {
background-color: #E6B800;
padding-top: 22px;
padding-bottom: 18px;
}
QPushButton:disabled {
background-color: #555555;
color: #cccccc;
border: none;
}
"""
BigSuccessLabel = """
QLabel {
color: #ffffff;
font-size: 26px;
font-weight: bold;
font-family: "Segoe UI", sans-serif;
}"""
colors = [
'#FF6F61', # яркий коралловый
'#6B5B95', # приглушенный фиолетовый
'#88B04B', # яркий зеленый
'#F7CAC9', # светлый розовый
'#92A8D1', # светло-голубой
'#955251', # теплый терракотовый
'#B565A7', # лавандовый
'#009B77', # глубокий бирюзовый
'#DD4124', # ярко-красный
'#45B8AC' # мягкий мятный
]
RGBA = [(255, 255, 0),
(32, 178, 70),
(255, 69, 0),
(123, 104, 238),
(99, 42, 15)
]

View File

@ -6,7 +6,7 @@ from PyQt5.QtWidgets import (QWidget, QPushButton,
from PyQt5.QtGui import QIntValidator
from utils.json_tools import read_json, write_json
from gui import qt_settings as qts
from utils import qt_settings as qts
class settingsWindow(QWidget):
def __init__(self, path: str, name: str, upd_func: Callable[[], None]):
@ -71,7 +71,7 @@ class settingsWindow(QWidget):
layout.addLayout(control_layout)
layout.addWidget(self._param_table)
self.setLayout(layout)
self.setStyleSheet(qts.white_style)
self.setStyleSheet(qts.dark_style)
def _populate_table(self) -> None:
"""Заполняет таблицу значениями из self._data."""

Binary file not shown.

View File

@ -3,13 +3,15 @@ from __future__ import annotations
import os
from typing import Optional, Union, Any
from cachetools import LRUCache
import numpy as np
import pyqtgraph as pg
import pandas as pd
from PyQt5.QtCore import QObject, QTimer
from PyQt5.QtWidgets import QWidget, QTabWidget, QMainWindow, QVBoxLayout
from OptAlgorithm import OptAlgorithm
import numpy as np
import pyqtgraph as pg
from utils.qt_settings import dark_style
@ -412,7 +414,7 @@ class BaseMainWindow(QMainWindow):
# Устанавливаем основной вертикальный макет для центрального виджета
self._central_layout = QVBoxLayout()
self._central_widget.setLayout(self._central_layout)
self.set_style(self._central_widget)
self.set_style(self)
...
@property
@ -423,43 +425,8 @@ class BaseMainWindow(QMainWindow):
def controller(self, controller: BaseController) -> None:
self._controller = controller
def set_style(self, object: Union[QTabWidget, QWidget]) -> None:
object.setStyleSheet("""
QWidget {
background-color: #0D1117;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
QMessageBox {
background-color: #161B22;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
}
QPushButton {
background-color: #FFCC00;
color: #0D1117;
padding: 12px 25px;
border: 2px solid #E6B800;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
QPushButton:hover:!disabled {
background-color: #FFD700;
}
QPushButton:disabled {
background-color: #555555;
color: #cccccc;
border: none;
}
QLabel {
color: #ffffff;
font-size: 16px;
font-weight: bold;
font-family: "Segoe UI", sans-serif;
}
""")
def set_style(self, object: Union[QTabWidget, QWidget, QMainWindow]) -> None:
object.setStyleSheet(dark_style)
class BasePointPassportFormer:

458
src/utils/qt_settings.py Normal file
View File

@ -0,0 +1,458 @@
dark_style = """
/*
------------------------------------------------------
Общие стили и базовые настройки
------------------------------------------------------
*/
QWidget {
background-color: #0D1117; /* Основной фон приложения */
font-family: "Segoe UI", sans-serif;
font-size: 14px;
color: #E0E0E0; /* Светло-серый текст для контраста на тёмном фоне */
}
QMainWindow {
background-color: #0D1117;
/* Дополнительное визуальное разделение центральной части */
border: 1px solid #424242;
}
/*
------------------------------------------------------
Для небольшого визуального разделения между зонами
можно настроить QFrame, если используете фреймы:
QFrame {
border: 1px solid #424242;
border-radius: 4px;
}
------------------------------------------------------
*/
/*
------------------------------------------------------
Стиль для окон сообщений
------------------------------------------------------
*/
QMessageBox {
background-color: #0D1117;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
color: #E0E0E0;
}
/*
------------------------------------------------------
Кнопки (QPushButton)
------------------------------------------------------
*/
QPushButton {
background-color: #FFCC00; /* Жёлтый цвет акцент */
color: #121212;
padding: 10px 20px;
border: none;
border-radius: 6px;
font-size: 16px;
font-weight: 600;
}
/* Эффект при наведении */
QPushButton:hover:!disabled {
background-color: #FFD700; /* Более светлый жёлтый */
}
/* Эффект при нажатии */
QPushButton:pressed {
background-color: #E6B800; /* Более тёмный жёлтый */
}
/* Стиль для отключённых кнопок */
QPushButton:disabled {
background-color: #424242;
color: #BDBDBD;
}
/*
------------------------------------------------------
Чекбоксы и радиокнопки
------------------------------------------------------
*/
QCheckBox, QRadioButton {
color: #E0E0E0;
font-size: 14px;
font-weight: 500;
}
/*
------------------------------------------------------
Поля ввода (QLineEdit), спинбоксы, комбобоксы и т.п.
------------------------------------------------------
*/
QLineEdit, QComboBox {
background-color: #1E1E1E;
color: #E0E0E0;
padding: 8px;
border: 1px solid #424242;
border-radius: 4px;
font-size: 16px;
}
QSpinBox, QDoubleSpinBox {
background-color: #1E1E1E;
color: #E0E0E0;
padding: 5px;
border: 1px solid #424242;
border-radius: 4px;
font-size: 16px;
}
/*
------------------------------------------------------
Метки и группбоксы
------------------------------------------------------
*/
QLabel {
color: #E0E0E0;
font-size: 16px;
font-weight: 500;
}
QGroupBox {
color: #E0E0E0;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: 600;
border: 1px solid #424242;
border-radius: 6px;
margin-top: 10px;
padding: 10px;
}
/*
------------------------------------------------------
Меню и панель меню
------------------------------------------------------
*/
QMenuBar {
background-color: #1E1E1E;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: 600;
}
QMenuBar::item {
background: transparent;
padding: 18px 26px;
color: #E0E0E0;
}
QMenuBar::item:selected {
background-color: #333333;
color: #FFD700; /* Жёлтый при наведении */
}
QMenuBar::item:pressed {
background-color: #555555;
color: #FFD700; /* Жёлтый при нажатии */
}
QMenu {
background-color: #1E1E1E;
color: #E0E0E0;
border: 3px solid #424242;
}
QMenu::item {
padding: 10px 24px;
color: #E0E0E0;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: 600;
}
QMenu::item:selected {
background-color: #333333;
color: #FFD700;
}
QMenu::item:pressed {
background-color: #555555;
color: #FFD700;
}
/*
------------------------------------------------------
Полосы прокрутки (QScrollBar)
------------------------------------------------------
*/
QScrollBar:vertical {
background: #2C2C2C;
width: 12px;
margin: 0;
}
QScrollBar::handle:vertical {
background: #555555;
min-height: 20px;
border-radius: 6px;
}
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
background: #2C2C2C;
height: 0px;
subcontrol-origin: margin;
}
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
background: none;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
/*
------------------------------------------------------
Табы (QTabWidget, QTabBar)
------------------------------------------------------
*/
QTabWidget::pane {
border: 1px solid #424242;
background-color: #0D1117;
}
QTabBar::tab {
background: #1E1E1E;
color: #E0E0E0;
padding: 8px 16px;
margin: 2px;
border-radius: 4px;
}
QTabBar::tab:selected {
background: #333333;
font-weight: 600;
color: #FFD700; /* Выделим текст жёлтым при активной вкладке */
}
/*
------------------------------------------------------
Dock Widgets (QDockWidget)
------------------------------------------------------
*/
QDockWidget {
background: #1E1E1E;
border: 1px solid #424242;
}
/* Заголовок дока */
QDockWidget::title {
background-color: #2C2C2C;
text-align: left;
font-size: 14px;
font-weight: 600;
padding: 6px 10px;
border-bottom: 1px solid #424242;
color: #E0E0E0;
}
/* Кнопки закрытия и открепления (float) */ #FFD700
QDockWidget::close-button, QDockWidget::float-button {
border: none;
background-color: #FFCC00;
icon-size: 18px;
}
QDockWidget::close-button:hover, QDockWidget::float-button:hover {
background-color: #FFD700 ;
}
/*
------------------------------------------------------
Таблицы (QTableWidget / QTableView)
------------------------------------------------------
*/
QTableView {
background-color: #1E1E1E;
gridline-color: #424242; /* Линии сетки */
color: #E0E0E0; /* Текст ячеек */
border: 1px solid #424242;
selection-background-color: #FFCC00; /* Жёлтый при выделении */
selection-color: #121212; /* Тёмный цвет текста при выделении */
}
/* Горизонтальный заголовок в таблицах */
QHeaderView::section {
background-color: #2C2C2C;
color: #E0E0E0;
padding: 6px;
border: 1px solid #424242;
font-weight: 600;
font-size: 14px;
}
/* Вертикальный заголовок в таблицах */
QHeaderView::section:vertical {
background-color: #2C2C2C;
color: #E0E0E0;
padding: 4px;
border: 1px solid #424242;
font-weight: 600;
font-size: 14px;
}
/* Полоса прокрутки в QTableView (если своя нужна) */
QTableView QScrollBar:vertical {
background: #2C2C2C;
width: 12px;
margin: 0;
}
QTableView QScrollBar::handle:vertical {
background: #555555;
min-height: 20px;
border-radius: 6px;
}
/*
При желании можно добавить эффекты при наведении/клике на строки QTableView:
QTableView::item:hover {
background-color: #333333;
color: #FFD700;
}
*/
/*
------------------------------------------------------
Завершение стиля
------------------------------------------------------
*/
"""
dis_robots = """
QPushButton {
background-color: #555555;
color: #cccccc;
padding: 12px 25px;
border: none;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
}
QWidget#robot {
border: none;
padding: 5px;
background-color: rgba(33, 33, 33, 100);
}
"""
selected_robot = """
QWidget#robot {
border: 2px solid #E6B800;
border-radius: 10px;
padding: 5px;
}
"""
en_button = """
QPushButton {
background-color: #FFCC00;
color: #0D1117;
padding: 12px 25px;
border: 2px solid #E6B800;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
QPushButton:hover:!disabled {
background-color: #FFD700;
}
"""
dis_button = """
QPushButton {
background-color: #555555;
color: #cccccc;
padding: 12px 25px;
border: none;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
}
"""
saved_button = """
QPushButton {
background-color: #28a745;
color: #ffffff;
padding: 12px 25px;
border: none;
border-radius: 8px;
font-family: "Segoe UI", sans-serif;
font-size: 16px;
font-weight: bold;
}
"""
start_button = """
QPushButton {
background-color: #FFCC00;
color: #0D1117;
padding: 20px 40px;
border: 2px solid #E6B800;
border-radius: 10px;
font-family: "Segoe UI", sans-serif;
font-size: 24px;
font-weight: bold;
background-image: linear-gradient(to bottom, #FFD700, #FFCC00);
}
QPushButton:hover:!disabled {
background-color: #FFD700;
}
QPushButton:pressed {
background-color: #E6B800;
padding-top: 22px;
padding-bottom: 18px;
}
QPushButton:disabled {
background-color: #555555;
color: #cccccc;
border: none;
}
"""
BigSuccessLabel = """
QLabel {
color: #ffffff;
font-size: 26px;
font-weight: bold;
font-family: "Segoe UI", sans-serif;
}"""
colors = [
'#FF6F61', # яркий коралловый
'#6B5B95', # приглушенный фиолетовый
'#88B04B', # яркий зеленый
'#F7CAC9', # светлый розовый
'#92A8D1', # светло-голубой
'#955251', # теплый терракотовый
'#B565A7', # лавандовый
'#009B77', # глубокий бирюзовый
'#DD4124', # ярко-красный
'#45B8AC' # мягкий мятный
]
RGBA = [(255, 255, 0),
(32, 178, 70),
(255, 69, 0),
(123, 104, 238),
(99, 42, 15)
]