From bcfbbe33e82a62fe8957426acfa77ebb8e3e70a8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 9 Jan 2026 01:09:22 +0300 Subject: [PATCH] add screen folder --- screens/setting/__init__.py | 1 + screens/setting/about_screen.py | 78 +++++++++++++ .../bluetooth_screen.py} | 0 screens/setting/dev_screen.py | 22 ++++ screens/settings.py | 109 +----------------- 5 files changed, 106 insertions(+), 104 deletions(-) create mode 100644 screens/setting/__init__.py create mode 100644 screens/setting/about_screen.py rename screens/{bluetooth.py => setting/bluetooth_screen.py} (100%) create mode 100644 screens/setting/dev_screen.py diff --git a/screens/setting/__init__.py b/screens/setting/__init__.py new file mode 100644 index 0000000..ddcd826 --- /dev/null +++ b/screens/setting/__init__.py @@ -0,0 +1 @@ +"""Settings sub-screens.""" diff --git a/screens/setting/about_screen.py b/screens/setting/about_screen.py new file mode 100644 index 0000000..ec081bb --- /dev/null +++ b/screens/setting/about_screen.py @@ -0,0 +1,78 @@ +from PySide6.QtWidgets import ( + QWidget, + QLabel, + QVBoxLayout, + QHBoxLayout, + QScrollArea, +) +from PySide6.QtCore import Qt +from PySide6.QtGui import QFont +from PySide6.QtWidgets import QScroller +import build_info + + +def build_about_screen() -> QWidget: + screen = QWidget() + layout = QVBoxLayout(screen) + layout.setContentsMargins(0, 0, 0, 0) + layout.setSpacing(12) + + scroll = QScrollArea() + scroll.setWidgetResizable(True) + scroll.setFrameShape(QScrollArea.NoFrame) + scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + + scroller = QScroller.scroller(scroll.viewport()) + scroller.grabGesture( + scroll.viewport(), + QScroller.LeftMouseButtonGesture + ) + + content = QWidget() + content_layout = QVBoxLayout(content) + content_layout.setContentsMargins(0, 0, 0, 0) + content_layout.setSpacing(12) + + info = QVBoxLayout() + info.setContentsMargins(0, 0, 0, 0) + info.setSpacing(8) + + info.addWidget(_info_row("Приложение", build_info.APP_NAME)) + info.addWidget(_info_row("Версия", build_info.VERSION)) + info.addWidget(_info_row("Сборка", build_info.BUILD_DATE)) + info.addWidget(_info_row("Коммит", build_info.GIT_HASH)) + info.addWidget(_info_row("Устройство", build_info.get_device_model())) + info.addWidget(_info_row("ОС", build_info.get_os_pretty_name())) + info.addWidget(_info_row("Ядро", build_info.get_kernel_version())) + info.addWidget(_info_row("RAM (используется/всего)", build_info.get_ram_info())) + info.addWidget(_info_row("Диск (используется/всего)", build_info.get_disk_info())) + info.addWidget(_info_row("Серийный номер", build_info.get_serial_number())) + info.addWidget(_info_row("IP", build_info.get_ip_address())) + info.addWidget(_info_row("Температура CPU", build_info.get_cpu_temp())) + + content_layout.addLayout(info) + content_layout.addStretch(1) + + scroll.setWidget(content) + layout.addWidget(scroll) + return screen + + +def _info_row(label: str, value: str) -> QWidget: + row = QWidget() + layout = QHBoxLayout(row) + layout.setContentsMargins(12, 6, 12, 6) + layout.setSpacing(12) + + lbl = QLabel(label) + lbl.setFont(QFont("", 15, 600)) + + val = QLabel(value) + val.setFont(QFont("", 15)) + val.setAlignment(Qt.AlignRight | Qt.AlignVCenter) + + layout.addWidget(lbl) + layout.addStretch(1) + layout.addWidget(val) + return row diff --git a/screens/bluetooth.py b/screens/setting/bluetooth_screen.py similarity index 100% rename from screens/bluetooth.py rename to screens/setting/bluetooth_screen.py diff --git a/screens/setting/dev_screen.py b/screens/setting/dev_screen.py new file mode 100644 index 0000000..deb2d17 --- /dev/null +++ b/screens/setting/dev_screen.py @@ -0,0 +1,22 @@ +from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton + + +def build_dev_screen(on_exit) -> QWidget: + screen = QWidget() + layout = QVBoxLayout(screen) + layout.setContentsMargins(0, 0, 0, 0) + layout.setSpacing(12) + + hdr = QHBoxLayout() + hdr.setContentsMargins(0, 0, 0, 0) + hdr.setSpacing(12) + + exit_btn = QPushButton("Переход к рабочему столу") + exit_btn.setObjectName("DevExitBtn") + exit_btn.setMinimumHeight(72) + exit_btn.clicked.connect(on_exit) + + layout.addLayout(hdr) + layout.addWidget(exit_btn) + layout.addStretch(1) + return screen diff --git a/screens/settings.py b/screens/settings.py index 3b38086..6a79d60 100644 --- a/screens/settings.py +++ b/screens/settings.py @@ -12,8 +12,9 @@ from PySide6.QtWidgets import ( from PySide6.QtCore import Qt, Signal from PySide6.QtGui import QFont from PySide6.QtWidgets import QScroller -from screens.bluetooth import BluetoothScreen -import build_info +from screens.setting.bluetooth_screen import BluetoothScreen +from screens.setting.about_screen import build_about_screen +from screens.setting.dev_screen import build_dev_screen class SettingsRow(QPushButton): @@ -128,8 +129,8 @@ class SettingsScreen(QWidget): scroll.setWidget(content) list_layout.addWidget(scroll, 1) - self._dev_screen = self._build_dev_screen() - self._about_screen = self._build_about_screen() + self._dev_screen = build_dev_screen(self._exit_app) + self._about_screen = build_about_screen() self._bt_screen = BluetoothScreen(self._show_list) self.stack.addWidget(self._list_screen) self.stack.addWidget(self._dev_screen) @@ -144,38 +145,6 @@ class SettingsScreen(QWidget): bt_row.clicked.connect(self._show_bluetooth) self._show_list() - def _build_dev_screen(self) -> QWidget: - screen = QWidget() - layout = QVBoxLayout(screen) - layout.setContentsMargins(0, 0, 0, 0) - layout.setSpacing(12) - - hdr = QHBoxLayout() - hdr.setContentsMargins(0, 0, 0, 0) - hdr.setSpacing(12) - - # back_btn = QPushButton("Назад") - # back_btn.setObjectName("SettingsBackBtn") - # back_btn.setMinimumSize(120, 44) - # back_btn.clicked.connect(self._show_list) - - # title = QLabel("Параметры разработчика") - # title.setFont(QFont("", 22, 700)) - - # hdr.addWidget(back_btn) - # hdr.addWidget(title) - # hdr.addStretch(1) - - exit_btn = QPushButton("Переход к рабочему столу") - exit_btn.setObjectName("DevExitBtn") - exit_btn.setMinimumHeight(72) - exit_btn.clicked.connect(self._exit_app) - - layout.addLayout(hdr) - layout.addWidget(exit_btn) - layout.addStretch(1) - return screen - def _add_section( self, root: QVBoxLayout, @@ -195,74 +164,6 @@ class SettingsScreen(QWidget): rows[row_title] = row return rows - def _build_about_screen(self) -> QWidget: - screen = QWidget() - layout = QVBoxLayout(screen) - layout.setContentsMargins(0, 0, 0, 0) - layout.setSpacing(12) - - scroll = QScrollArea() - scroll.setWidgetResizable(True) - scroll.setFrameShape(QScrollArea.NoFrame) - scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - - scroller = QScroller.scroller(scroll.viewport()) - scroller.grabGesture( - scroll.viewport(), - QScroller.LeftMouseButtonGesture - ) - - content = QWidget() - content_layout = QVBoxLayout(content) - content_layout.setContentsMargins(0, 0, 0, 0) - content_layout.setSpacing(12) - - info = QVBoxLayout() - info.setContentsMargins(0, 0, 0, 0) - info.setSpacing(8) - - info.addWidget(self._info_row("Приложение", build_info.APP_NAME)) - info.addWidget(self._info_row("Версия", build_info.VERSION)) - info.addWidget(self._info_row("Сборка", build_info.BUILD_DATE)) - info.addWidget(self._info_row("Коммит", build_info.GIT_HASH)) - info.addWidget(self._info_row("Устройство", build_info.get_device_model())) - info.addWidget(self._info_row("ОС", build_info.get_os_pretty_name())) - info.addWidget(self._info_row("Ядро", build_info.get_kernel_version())) - info.addWidget(self._info_row("RAM (используется/всего)", build_info.get_ram_info())) - info.addWidget(self._info_row("Диск (используется/всего)", build_info.get_disk_info())) - info.addWidget(self._info_row("Серийный номер", build_info.get_serial_number())) - info.addWidget(self._info_row("IP", build_info.get_ip_address())) - info.addWidget(self._info_row("Температура CPU", build_info.get_cpu_temp())) - - # title = QLabel("Об устройстве") - # title.setFont(QFont("", 22, 700)) - # content_layout.addWidget(title) - content_layout.addLayout(info) - content_layout.addStretch(1) - - scroll.setWidget(content) - layout.addWidget(scroll) - return screen - - def _info_row(self, label: str, value: str) -> QWidget: - row = QWidget() - layout = QHBoxLayout(row) - layout.setContentsMargins(12, 6, 12, 6) - layout.setSpacing(12) - - lbl = QLabel(label) - lbl.setFont(QFont("", 15, 600)) - - val = QLabel(value) - val.setFont(QFont("", 15)) - val.setAlignment(Qt.AlignRight | Qt.AlignVCenter) - - layout.addWidget(lbl) - layout.addStretch(1) - layout.addWidget(val) - return row - def _show_dev(self): self.stack.setCurrentWidget(self._dev_screen) self.view_changed.emit("Параметры разработчика", True)