settings
This commit is contained in:
parent
70cbdfd9bc
commit
6875cccccc
@ -1,6 +1,17 @@
|
||||
from PySide6.QtWidgets import QWidget, QLabel, QVBoxLayout, QHBoxLayout, QPushButton, QSizePolicy, QScrollArea
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget,
|
||||
QLabel,
|
||||
QVBoxLayout,
|
||||
QHBoxLayout,
|
||||
QPushButton,
|
||||
QSizePolicy,
|
||||
QScrollArea,
|
||||
QStackedWidget,
|
||||
QApplication,
|
||||
)
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QFont
|
||||
from PySide6.QtWidgets import QScroller
|
||||
|
||||
|
||||
class SettingsRow(QPushButton):
|
||||
@ -49,14 +60,30 @@ class SettingsScreen(QWidget):
|
||||
root.setContentsMargins(18, 16, 18, 16)
|
||||
root.setSpacing(12)
|
||||
|
||||
title = QLabel("Настройки")
|
||||
title.setFont(QFont("", 24, 700))
|
||||
root.addWidget(title)
|
||||
self.stack = QStackedWidget()
|
||||
root.addWidget(self.stack, 1)
|
||||
|
||||
self._list_screen = QWidget()
|
||||
list_layout = QVBoxLayout(self._list_screen)
|
||||
list_layout.setContentsMargins(0, 0, 0, 0)
|
||||
list_layout.setSpacing(12)
|
||||
|
||||
list_title = QLabel("Настройки")
|
||||
list_title.setFont(QFont("", 24, 700))
|
||||
list_layout.addWidget(list_title)
|
||||
|
||||
scroll = QScrollArea()
|
||||
scroll.setWidgetResizable(True)
|
||||
scroll.setFrameShape(QScrollArea.NoFrame)
|
||||
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
|
||||
# === TOUCH SCROLL (Raspberry safe) ===
|
||||
scroller = QScroller.scroller(scroll.viewport())
|
||||
scroller.grabGesture(
|
||||
scroll.viewport(),
|
||||
QScroller.LeftMouseButtonGesture
|
||||
)
|
||||
|
||||
content = QWidget()
|
||||
content_layout = QVBoxLayout(content)
|
||||
@ -72,13 +99,14 @@ class SettingsScreen(QWidget):
|
||||
],
|
||||
)
|
||||
|
||||
self._add_section(
|
||||
dev_row = self._add_section(
|
||||
content_layout,
|
||||
"Система",
|
||||
[
|
||||
("Об устройстве", "Версия, память, серийный номер"),
|
||||
("Параметры разработчика", "Отладка и логирование"),
|
||||
],
|
||||
return_row_title="Параметры разработчика",
|
||||
)
|
||||
|
||||
self._add_section(
|
||||
@ -92,14 +120,75 @@ class SettingsScreen(QWidget):
|
||||
|
||||
content_layout.addStretch(1)
|
||||
scroll.setWidget(content)
|
||||
root.addWidget(scroll, 1)
|
||||
list_layout.addWidget(scroll, 1)
|
||||
|
||||
def _add_section(self, root: QVBoxLayout, title: str, items: list[tuple[str, str]]):
|
||||
self._dev_screen = self._build_dev_screen()
|
||||
self.stack.addWidget(self._list_screen)
|
||||
self.stack.addWidget(self._dev_screen)
|
||||
|
||||
if dev_row is not None:
|
||||
dev_row.clicked.connect(self._show_dev)
|
||||
|
||||
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,
|
||||
title: str,
|
||||
items: list[tuple[str, str]],
|
||||
return_row_title: str | None = None,
|
||||
):
|
||||
section = QLabel(title)
|
||||
section.setObjectName("SettingsSection")
|
||||
section.setFont(QFont("", 14, 700))
|
||||
section.setContentsMargins(2, 8, 2, 0)
|
||||
root.addWidget(section)
|
||||
|
||||
target_row = None
|
||||
for row_title, row_subtitle in items:
|
||||
root.addWidget(SettingsRow(row_title, row_subtitle))
|
||||
row = SettingsRow(row_title, row_subtitle)
|
||||
root.addWidget(row)
|
||||
if return_row_title and row_title == return_row_title:
|
||||
target_row = row
|
||||
return target_row
|
||||
|
||||
def _show_dev(self):
|
||||
self.stack.setCurrentWidget(self._dev_screen)
|
||||
|
||||
def _show_list(self):
|
||||
self.stack.setCurrentWidget(self._list_screen)
|
||||
|
||||
def _exit_app(self):
|
||||
app = QApplication.instance()
|
||||
if app is not None:
|
||||
app.quit()
|
||||
|
||||
@ -13,4 +13,20 @@ QWidget { background: #F4F6F8; color: #111827; }
|
||||
#SettingsRowTitle { color: #111827; }
|
||||
#SettingsRowSub { color: rgba(107,114,128,0.95); }
|
||||
#SettingsChevron { color: rgba(107,114,128,0.95); }
|
||||
|
||||
#SettingsBackBtn {
|
||||
background: #FFFFFF;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #E5E7EB;
|
||||
padding: 8px 14px;
|
||||
}
|
||||
#SettingsBackBtn:hover { background: #F9FAFB; }
|
||||
#DevExitBtn {
|
||||
background: #F3F4F6;
|
||||
border-radius: 14px;
|
||||
border: 1px solid #E5E7EB;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
#DevExitBtn:hover { background: #E5E7EB; }
|
||||
"""
|
||||
|
||||
@ -12,4 +12,18 @@ QWidget { background: #0B0E11; color: #E6EAF0; }
|
||||
#SettingsRowTitle { color: #E6EAF0; }
|
||||
#SettingsRowSub { color: rgba(138,147,166,0.95); }
|
||||
#SettingsChevron { color: rgba(138,147,166,0.95); }
|
||||
|
||||
#SettingsBackBtn {
|
||||
background: #141A22;
|
||||
border-radius: 12px;
|
||||
padding: 8px 14px;
|
||||
}
|
||||
#SettingsBackBtn:hover { background: #1B2330; }
|
||||
#DevExitBtn {
|
||||
background: #1B2330;
|
||||
border-radius: 14px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
#DevExitBtn:hover { background: #263142; }
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user