update design bl
This commit is contained in:
parent
5f6e1098d3
commit
28a795558e
@ -111,11 +111,97 @@ def _build_sound_toggles() -> QWidget:
|
||||
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(
|
||||
label: str,
|
||||
settings: QSettings,
|
||||
key: str,
|
||||
default: bool,
|
||||
flag_path: Path | None = None,
|
||||
) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
@ -128,7 +214,10 @@ def _toggle_row(
|
||||
btn = QPushButton("Выкл")
|
||||
btn.setObjectName("SoundToggle")
|
||||
btn.setCheckable(True)
|
||||
btn.setChecked(_read_bool_setting(settings, key, default))
|
||||
if flag_path:
|
||||
btn.setChecked(flag_path.exists())
|
||||
else:
|
||||
btn.setChecked(_read_bool_setting(settings, key, default))
|
||||
btn.setMinimumHeight(40)
|
||||
btn.setMinimumWidth(110)
|
||||
btn.setFont(QFont("", 12, 700))
|
||||
@ -137,7 +226,14 @@ def _toggle_row(
|
||||
btn.setText("Вкл" if is_checked else "Выкл")
|
||||
|
||||
def _persist_flag(is_checked: bool):
|
||||
settings.setValue(key, is_checked)
|
||||
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)
|
||||
|
||||
btn.toggled.connect(_sync_text)
|
||||
btn.toggled.connect(_persist_flag)
|
||||
@ -169,44 +265,6 @@ def _mock_devices_flag_path() -> Path:
|
||||
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):
|
||||
dialog = ConfirmDialog(
|
||||
"Подтверждение",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user