diff --git a/files/style.qss b/files/style.qss new file mode 100644 index 0000000..46409c1 --- /dev/null +++ b/files/style.qss @@ -0,0 +1,117 @@ +/* style.qss - Windows 10/11 Light Theme */ + +/* Global settings */ +QWidget { + font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 13px; + color: #000000; +} + +/* Main Windows and Dialogs Background */ +QMainWindow, QDialog { + background-color: #F3F3F3; +} + +/* Buttons */ +QPushButton { + background-color: #0078D4; /* Windows blue accent */ + color: #FFFFFF; + border: 1px solid #005A9E; + border-radius: 4px; + padding: 6px 12px; +} + +QPushButton:hover { + background-color: #005A9E; /* Slightly darker on hover */ +} + +QPushButton:pressed { + background-color: #004578; /* Even darker on press */ +} + +QPushButton:disabled { + background-color: #CCCCCC; + color: #666666; + border: 1px solid #AAAAAA; +} + +/* Input Fields (QLineEdit, QTextEdit, QComboBox) */ +QLineEdit, QTextEdit, QComboBox, QDateEdit, QTimeEdit, QDateTimeEdit { + background-color: #FFFFFF; + border: 1px solid #CCCCCC; + border-radius: 4px; + padding: 4px; + selection-background-color: #0078D4; + selection-color: #FFFFFF; +} + +QLineEdit:focus, QTextEdit:focus, QComboBox:focus, QDateEdit:focus, QTimeEdit:focus, QDateTimeEdit:focus { + border: 1px solid #0078D4; /* Accent color border on focus */ +} + +QLineEdit:disabled, QTextEdit:disabled, QComboBox:disabled, QDateEdit:disabled { + background-color: #E6E6E6; + color: #888888; +} + +/* Table Widget */ +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: #F0F0F0; + border: 1px solid #CCCCCC; + padding: 4px; + font-weight: bold; +} + +/* Group Boxes */ +QGroupBox { + border: 1px solid #CCCCCC; + border-radius: 4px; + margin-top: 1ex; /* leave space at the top for the title */ + padding-top: 10px; +} + +QGroupBox::title { + subcontrol-origin: margin; + subcontrol-position: top left; /* position at the top left */ + padding: 0 3px; + color: #0078D4; +} + +/* Labels */ +QLabel { + background: transparent; +} + +/* Tab Widget */ +QTabWidget::pane { + border: 1px solid #CCCCCC; + background-color: #FFFFFF; +} + +QTabBar::tab { + background-color: #E1E1E1; + border: 1px solid #CCCCCC; + border-bottom-color: #CCCCCC; /* same as the pane color */ + border-top-left-radius: 4px; + border-top-right-radius: 4px; + min-width: 8ex; + padding: 6px 12px; +} + +QTabBar::tab:selected, QTabBar::tab:hover { + background-color: #FFFFFF; +} + +QTabBar::tab:selected { + border-color: #CCCCCC; + border-bottom-color: #FFFFFF; /* same as pane color */ +} diff --git a/main.py b/main.py index c7f54d0..11bb0f3 100644 --- a/main.py +++ b/main.py @@ -222,7 +222,9 @@ def show_main_window(): f"PyMASL ver. {system.software_version}. Пользователь: {user_full_name}. БД: {system.database}" ) window.main_button_all_sales() - window.exec_() + # Сохраняем ссылку на окно, чтобы сборщик мусора не удалил его + QtWidgets.QApplication.instance().main_window = window + window.showMaximized() @@ -429,7 +431,7 @@ def edit_client_in_sale(self) -> None: # Сохраняем параметры данных об уже существующем клиенте system.client_update = 1 logger.info(f"Обновляем инф. клиента {system.client_id}") - client.exec_() + client.exec() def adding_new_client_to_sale(self) -> None: """ @@ -2344,7 +2346,7 @@ def open_pay_form(self, txt): # Передаем текст в форму PayForm pay.setText(txt) - res: int = pay.exec_() + res: int = pay.exec() # если пользователь нажал крестик или кнопку Escape, # то по-умолчанию возвращается QDialog.Rejected if res == QDialog.Rejected: @@ -2523,7 +2525,7 @@ def get_slip(self) -> None: slip.ui.lineEdit.setText(rrn_value) slip.ui.textEdit.setText(load_slip) slip.show() - slip.exec_() + slip.exec() class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): @@ -3130,7 +3132,7 @@ def main_search_selected_sale(self) -> None: system.sale_id = int(sale_number) system.sale_tickets = client_in_sale logger.debug(f"Билеты сохраненной продажи: {system.sale_tickets}") - sale.exec_() + sale.exec() @logger_wraps(entry=True, exit=True, level="DEBUG") def main_button_all_sales(self) -> None: @@ -3316,7 +3318,7 @@ def main_open_sale(self) -> None: system.sale_id = None system.sale_status = 0 # Т.е. новая продажа system.sale_tickets = None - sale.exec_() + sale.exec() def main_get_statistic(self) -> None: """ @@ -3556,7 +3558,22 @@ class Payment: if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) app.setStyle("Fusion") + + # Загружаем QSS стили + try: + style_path = Path(__file__).parent / "files" / "style.qss" + if style_path.exists(): + with open(style_path, "r", encoding="utf-8") as style_file: + app.setStyleSheet(style_file.read()) + else: + logger.warning(f"Файл стилей не найден: {style_path}") + except Exception as e: + logger.error(f"Ошибка при загрузке стилей: {e}") + auth = AuthForm() auth.show() auth.ui.label_9.setText(system.database) - sys.exit(app.exec()) + + exit_code = app.exec() + logger.complete() + sys.exit(exit_code)