car_ui/screens/settings.py
2026-01-08 02:13:30 +03:00

106 lines
3.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from PySide6.QtWidgets import QWidget, QLabel, QVBoxLayout, QHBoxLayout, QPushButton, QSizePolicy, QScrollArea
from PySide6.QtCore import Qt
from PySide6.QtGui import QFont
class SettingsRow(QPushButton):
def __init__(self, title: str, subtitle: str):
super().__init__()
self.setObjectName("SettingsRow")
self.setCursor(Qt.PointingHandCursor)
self.setCheckable(False)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.setMinimumHeight(70)
row = QHBoxLayout(self)
row.setContentsMargins(16, 10, 16, 10)
row.setSpacing(12)
text_col = QVBoxLayout()
text_col.setContentsMargins(0, 0, 0, 0)
text_col.setSpacing(2)
lbl_title = QLabel(title)
lbl_title.setObjectName("SettingsRowTitle")
lbl_title.setFont(QFont("", 16, 600))
lbl_sub = QLabel(subtitle)
lbl_sub.setObjectName("SettingsRowSub")
lbl_sub.setFont(QFont("", 12))
lbl_sub.setWordWrap(True)
text_col.addWidget(lbl_title)
text_col.addWidget(lbl_sub)
chevron = QLabel("")
chevron.setObjectName("SettingsChevron")
chevron.setFont(QFont("", 20, 600))
chevron.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
row.addLayout(text_col)
row.addStretch(1)
row.addWidget(chevron)
class SettingsScreen(QWidget):
def __init__(self):
super().__init__()
root = QVBoxLayout(self)
root.setContentsMargins(18, 16, 18, 16)
root.setSpacing(12)
title = QLabel("Настройки")
title.setFont(QFont("", 24, 700))
root.addWidget(title)
scroll = QScrollArea()
scroll.setWidgetResizable(True)
scroll.setFrameShape(QScrollArea.NoFrame)
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
content = QWidget()
content_layout = QVBoxLayout(content)
content_layout.setContentsMargins(0, 0, 0, 0)
content_layout.setSpacing(12)
self._add_section(
content_layout,
"Сеть",
[
("Wi-Fi", "Доступные сети и подключение"),
("Bluetooth", "Сопряжение и устройства"),
],
)
self._add_section(
content_layout,
"Система",
[
("Об устройстве", "Версия, память, серийный номер"),
("Параметры разработчика", "Отладка и логирование"),
],
)
self._add_section(
content_layout,
"Дисплей и звук",
[
("Экран", "Яркость, сон, тема"),
("Звук", "Громкость, эквалайзер"),
],
)
content_layout.addStretch(1)
scroll.setWidget(content)
root.addWidget(scroll, 1)
def _add_section(self, root: QVBoxLayout, title: str, items: list[tuple[str, str]]):
section = QLabel(title)
section.setObjectName("SettingsSection")
section.setFont(QFont("", 14, 700))
section.setContentsMargins(2, 8, 2, 0)
root.addWidget(section)
for row_title, row_subtitle in items:
root.addWidget(SettingsRow(row_title, row_subtitle))