add screen folder
This commit is contained in:
parent
2d251d1131
commit
bcfbbe33e8
1
screens/setting/__init__.py
Normal file
1
screens/setting/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""Settings sub-screens."""
|
||||||
78
screens/setting/about_screen.py
Normal file
78
screens/setting/about_screen.py
Normal file
@ -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
|
||||||
22
screens/setting/dev_screen.py
Normal file
22
screens/setting/dev_screen.py
Normal file
@ -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
|
||||||
@ -12,8 +12,9 @@ from PySide6.QtWidgets import (
|
|||||||
from PySide6.QtCore import Qt, Signal
|
from PySide6.QtCore import Qt, Signal
|
||||||
from PySide6.QtGui import QFont
|
from PySide6.QtGui import QFont
|
||||||
from PySide6.QtWidgets import QScroller
|
from PySide6.QtWidgets import QScroller
|
||||||
from screens.bluetooth import BluetoothScreen
|
from screens.setting.bluetooth_screen import BluetoothScreen
|
||||||
import build_info
|
from screens.setting.about_screen import build_about_screen
|
||||||
|
from screens.setting.dev_screen import build_dev_screen
|
||||||
|
|
||||||
|
|
||||||
class SettingsRow(QPushButton):
|
class SettingsRow(QPushButton):
|
||||||
@ -128,8 +129,8 @@ class SettingsScreen(QWidget):
|
|||||||
scroll.setWidget(content)
|
scroll.setWidget(content)
|
||||||
list_layout.addWidget(scroll, 1)
|
list_layout.addWidget(scroll, 1)
|
||||||
|
|
||||||
self._dev_screen = self._build_dev_screen()
|
self._dev_screen = build_dev_screen(self._exit_app)
|
||||||
self._about_screen = self._build_about_screen()
|
self._about_screen = build_about_screen()
|
||||||
self._bt_screen = BluetoothScreen(self._show_list)
|
self._bt_screen = BluetoothScreen(self._show_list)
|
||||||
self.stack.addWidget(self._list_screen)
|
self.stack.addWidget(self._list_screen)
|
||||||
self.stack.addWidget(self._dev_screen)
|
self.stack.addWidget(self._dev_screen)
|
||||||
@ -144,38 +145,6 @@ class SettingsScreen(QWidget):
|
|||||||
bt_row.clicked.connect(self._show_bluetooth)
|
bt_row.clicked.connect(self._show_bluetooth)
|
||||||
self._show_list()
|
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(
|
def _add_section(
|
||||||
self,
|
self,
|
||||||
root: QVBoxLayout,
|
root: QVBoxLayout,
|
||||||
@ -195,74 +164,6 @@ class SettingsScreen(QWidget):
|
|||||||
rows[row_title] = row
|
rows[row_title] = row
|
||||||
return rows
|
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):
|
def _show_dev(self):
|
||||||
self.stack.setCurrentWidget(self._dev_screen)
|
self.stack.setCurrentWidget(self._dev_screen)
|
||||||
self.view_changed.emit("Параметры разработчика", True)
|
self.view_changed.emit("Параметры разработчика", True)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user