From 46ed6c0a46b4f5317f73356c1770661fd39b5160 Mon Sep 17 00:00:00 2001 From: MarcusStill <69536339+MarcusStill@users.noreply.github.com> Date: Tue, 8 Sep 2026 17:06:23 +0000 Subject: [PATCH] Add modern Windows 10/11 styling using QSS Creates `files/style.qss` containing flat design styles with the #0078D4 accent color and Segoe UI font. Updates `main.py` to securely load and apply these styles on top of the 'Fusion' base style. --- files/style.qss | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ main.py | 9 ++++ 2 files changed, 119 insertions(+) create mode 100644 files/style.qss diff --git a/files/style.qss b/files/style.qss new file mode 100644 index 0000000..88ac0ff --- /dev/null +++ b/files/style.qss @@ -0,0 +1,110 @@ +/* Базовые настройки приложения */ +* { + font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + color: #333333; +} + +/* Фон для основных окон */ +QMainWindow, QDialog { + background-color: #F3F3F3; +} + +/* Поля ввода (QLineEdit, QTextEdit) */ +QLineEdit, QTextEdit { + background-color: #FFFFFF; + border: 1px solid #CCCCCC; + border-radius: 4px; + padding: 6px; + selection-background-color: #0078D4; + selection-color: #FFFFFF; +} + +QLineEdit:focus, QTextEdit:focus { + border: 1px solid #0078D4; + outline: none; +} + +/* Кнопки (QPushButton) */ +QPushButton { + background-color: #E1E1E1; + border: 1px solid #CCCCCC; + border-radius: 4px; + padding: 6px 12px; + color: #333333; +} + +QPushButton:hover { + background-color: #D4D4D4; + border-color: #BDBDBD; +} + +QPushButton:pressed { + background-color: #C0C0C0; + border-color: #9E9E9E; +} + +/* Первичные кнопки (Ok, Сохранить и т.д. можно настраивать по objectName, но здесь глобальный стиль) */ +/* Для применения акцентного цвета к конкретным кнопкам лучше использовать objectName, например: + QPushButton#pushButton_save { background-color: #0078D4; color: white; border: none; } +*/ + +/* Таблицы (QTableWidget) */ +QTableWidget { + background-color: #FFFFFF; + alternate-background-color: #F9F9F9; + border: 1px solid #CCCCCC; + gridline-color: #E0E0E0; + selection-background-color: #0078D4; + selection-color: #FFFFFF; +} + +QHeaderView::section { + background-color: #F3F3F3; + padding: 4px; + border: 1px solid #CCCCCC; + font-weight: bold; +} + +/* Вкладки (QTabWidget) */ +QTabWidget::pane { + border: 1px solid #CCCCCC; + background-color: #FFFFFF; +} + +QTabBar::tab { + background-color: #E1E1E1; + border: 1px solid #CCCCCC; + border-bottom-color: #CCCCCC; /* Одинаковая рамка вокруг вкладки */ + border-top-left-radius: 4px; + border-top-right-radius: 4px; + padding: 6px 16px; + margin-right: 2px; +} + +QTabBar::tab:selected { + background-color: #FFFFFF; + border-bottom-color: #FFFFFF; /* Убрать линию под выбранной вкладкой */ + font-weight: bold; +} + +QTabBar::tab:hover { + background-color: #D4D4D4; +} + +/* Лейблы */ +QLabel { + color: #333333; +} + +/* Выпадающие списки (QComboBox) - Избегаем переопределения drop-down и indicator */ +QComboBox { + background-color: #FFFFFF; + border: 1px solid #CCCCCC; + border-radius: 4px; + padding: 6px; +} + +QComboBox:focus { + border: 1px solid #0078D4; +} diff --git a/main.py b/main.py index c7f54d0..e0db19d 100644 --- a/main.py +++ b/main.py @@ -3556,6 +3556,15 @@ class Payment: if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) app.setStyle("Fusion") + + # Загрузка и применение стилей QSS + style_path = Path(__file__).parent / "files" / "style.qss" + try: + with open(style_path, "r", encoding="utf-8") as f: + app.setStyleSheet(f.read()) + except Exception as e: + logger.error(f"Не удалось загрузить файл стилей {style_path}: {e}") + auth = AuthForm() auth.show() auth.ui.label_9.setText(system.database)