from PySide6.QtWidgets import ( QWidget, QLabel, QVBoxLayout, QHBoxLayout, QScrollArea, ) from PySide6.QtCore import Qt, Signal from PySide6.QtGui import QFont, QGuiApplication from PySide6.QtWidgets import QScroller import build_info class AboutScreen(QWidget): dev_unlocked = Signal() def __init__(self): super().__init__() self._dev_taps = 0 self._build_row: _InfoRow | None = None self.dev_is_unlocked = build_info.DEV_MODE_ENABLE layout = QVBoxLayout(self) 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(_InfoRow("Приложение", build_info.APP_NAME)) info.addWidget(_InfoRow("Версия", build_info.VERSION)) self._build_row = _InfoRow("Сборка", build_info.BUILD_DATE, clickable=True) self._build_row.clicked.connect(self._on_build_tap) info.addWidget(self._build_row) info.addWidget(_InfoRow("Коммит", build_info.GIT_HASH)) info.addWidget(_InfoRow("Устройство", build_info.get_device_model())) info.addWidget(_InfoRow("ОС", build_info.get_os_pretty_name())) info.addWidget(_InfoRow("Ядро", build_info.get_kernel_version())) info.addWidget(_InfoRow("RAM (используется/всего)", build_info.get_ram_info())) info.addWidget(_InfoRow("Диск (используется/всего)", build_info.get_disk_info())) info.addWidget(_InfoRow("Экран", build_info.get_display_resolution())) info.addWidget(_InfoRow("Экран (факт)", _get_runtime_resolution())) info.addWidget(_InfoRow("Серийный номер", build_info.get_serial_number())) info.addWidget(_InfoRow("IP", build_info.get_ip_address())) info.addWidget(_InfoRow("Температура CPU", build_info.get_cpu_temp())) content_layout.addLayout(info) content_layout.addStretch(1) scroll.setWidget(content) layout.addWidget(scroll) def _on_build_tap(self): if self.dev_is_unlocked: return self._dev_taps += 1 remaining = 5 - self._dev_taps if self._build_row is None: return if remaining > 0: self._build_row.set_suffix(f"(Осталось {remaining} нажат.)") return if self._dev_taps >= 5: #self._dev_taps = 0 self._build_row.set_suffix("(Режим разработчика включен)") self.dev_unlocked.emit() self.dev_is_unlocked = True class _InfoRow(QWidget): clicked = Signal() def __init__(self, label: str, value: str, clickable: bool = False): super().__init__() self._base_label = label if clickable: self.setCursor(Qt.PointingHandCursor) layout = QHBoxLayout(self) layout.setContentsMargins(12, 6, 12, 6) layout.setSpacing(12) self._label = QLabel(label) self._label.setFont(QFont("", 15, 600)) self._value = QLabel(value) self._value.setFont(QFont("", 15)) self._value.setAlignment(Qt.AlignRight | Qt.AlignVCenter) layout.addWidget(self._label) layout.addStretch(1) layout.addWidget(self._value) self._clickable = clickable def mousePressEvent(self, event): if self._clickable and event.button() == Qt.LeftButton: self.clicked.emit() super().mousePressEvent(event) def set_suffix(self, suffix: str): suffix = suffix.strip() if suffix: self._label.setText(f"{self._base_label} {suffix}") else: self._label.setText(self._base_label) def _get_runtime_resolution() -> str: app = QGuiApplication.instance() if app is None: return "—" screen = app.primaryScreen() if screen is None: return "—" size = screen.size() if size.isEmpty(): return "—" return f"{size.width()}x{size.height()}"