update design bl

This commit is contained in:
cheykrym 2026-04-01 02:15:45 +03:00
parent 5f6e1098d3
commit 28a795558e

View File

@ -111,11 +111,97 @@ def _build_sound_toggles() -> QWidget:
return container return container
def _build_mock_devices_toggle() -> QWidget:
settings = QSettings("car_ui", "ui")
container = QWidget()
layout = QVBoxLayout(container)
layout.setContentsMargins(12, 6, 12, 6)
layout.setSpacing(8)
layout.addWidget(
_toggle_row(
"Mock Bluetooth устройства",
settings,
"debug/mock_devices",
False,
flag_path=_mock_devices_flag_path(),
)
)
return container
def _build_persist_toggle() -> QWidget:
row = QWidget()
layout = QHBoxLayout(row)
layout.setContentsMargins(12, 6, 12, 6)
layout.setSpacing(12)
lbl = QLabel("Показывать после перезагрузки")
lbl.setFont(QFont("", 14, 600))
btn = QPushButton("Выкл")
btn.setObjectName("SoundToggle")
btn.setCheckable(True)
btn.setChecked(_dev_flag_path().exists())
btn.setMinimumHeight(40)
btn.setMinimumWidth(110)
btn.setFont(QFont("", 12, 700))
def _sync_text(is_checked: bool):
btn.setText("Вкл" if is_checked else "Выкл")
def _persist_flag(is_checked: bool):
flag_path = _dev_flag_path()
if is_checked:
flag_path.touch(exist_ok=True)
else:
if flag_path.exists():
flag_path.unlink()
btn.toggled.connect(_sync_text)
btn.toggled.connect(_persist_flag)
_sync_text(btn.isChecked())
layout.addWidget(lbl)
layout.addStretch(1)
layout.addWidget(btn)
return row
def _build_sound_toggles() -> QWidget:
settings = QSettings("car_ui", "ui")
container = QWidget()
layout = QVBoxLayout(container)
layout.setContentsMargins(12, 6, 12, 6)
layout.setSpacing(8)
layout.addWidget(
_toggle_row(
"Премут",
settings,
"sound/premute_enabled",
False,
)
)
layout.addWidget(
_toggle_row(
"Ducking",
settings,
"sound/ducking_enabled",
False,
)
)
return container
def _toggle_row( def _toggle_row(
label: str, label: str,
settings: QSettings, settings: QSettings,
key: str, key: str,
default: bool, default: bool,
flag_path: Path | None = None,
) -> QWidget: ) -> QWidget:
row = QWidget() row = QWidget()
layout = QHBoxLayout(row) layout = QHBoxLayout(row)
@ -128,6 +214,9 @@ def _toggle_row(
btn = QPushButton("Выкл") btn = QPushButton("Выкл")
btn.setObjectName("SoundToggle") btn.setObjectName("SoundToggle")
btn.setCheckable(True) btn.setCheckable(True)
if flag_path:
btn.setChecked(flag_path.exists())
else:
btn.setChecked(_read_bool_setting(settings, key, default)) btn.setChecked(_read_bool_setting(settings, key, default))
btn.setMinimumHeight(40) btn.setMinimumHeight(40)
btn.setMinimumWidth(110) btn.setMinimumWidth(110)
@ -137,6 +226,13 @@ def _toggle_row(
btn.setText("Вкл" if is_checked else "Выкл") btn.setText("Вкл" if is_checked else "Выкл")
def _persist_flag(is_checked: bool): def _persist_flag(is_checked: bool):
if flag_path:
if is_checked:
flag_path.touch(exist_ok=True)
else:
if flag_path.exists():
flag_path.unlink()
else:
settings.setValue(key, is_checked) settings.setValue(key, is_checked)
btn.toggled.connect(_sync_text) btn.toggled.connect(_sync_text)
@ -169,44 +265,6 @@ def _mock_devices_flag_path() -> Path:
return Path(build_info.__file__).resolve().parent / "mock_devices_enable" return Path(build_info.__file__).resolve().parent / "mock_devices_enable"
def _build_mock_devices_toggle() -> QWidget:
row = QWidget()
layout = QHBoxLayout(row)
layout.setContentsMargins(12, 6, 12, 6)
layout.setSpacing(12)
lbl = QLabel("Mock Bluetooth устройства (debug)")
lbl.setFont(QFont("", 14, 600))
btn = QPushButton("Выкл")
btn.setObjectName("SoundToggle")
btn.setCheckable(True)
btn.setChecked(_mock_devices_flag_path().exists())
btn.setMinimumHeight(40)
btn.setMinimumWidth(110)
btn.setFont(QFont("", 12, 700))
def _sync_text(is_checked: bool):
btn.setText("Вкл" if is_checked else "Выкл")
def _persist_flag(is_checked: bool):
flag_path = _mock_devices_flag_path()
if is_checked:
flag_path.touch(exist_ok=True)
else:
if flag_path.exists():
flag_path.unlink()
btn.toggled.connect(_sync_text)
btn.toggled.connect(_persist_flag)
_sync_text(btn.isChecked())
layout.addWidget(lbl)
layout.addStretch(1)
layout.addWidget(btn)
return row
def _confirm_exit(on_exit): def _confirm_exit(on_exit):
dialog = ConfirmDialog( dialog = ConfirmDialog(
"Подтверждение", "Подтверждение",