From 848a9e464c14ef1acf60715ebb0166cf7e8f81c0 Mon Sep 17 00:00:00 2001 From: cheykrym Date: Wed, 1 Apr 2026 02:06:09 +0300 Subject: [PATCH] update design bl --- screens/setting/dev_screen.py | 43 +++++++++++++++++++++++++++++++++++ services/bluetooth_service.py | 8 +++++-- themes/day.py | 3 +++ themes/night.py | 3 +++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/screens/setting/dev_screen.py b/screens/setting/dev_screen.py index 6f0b28a..dd4ecb0 100644 --- a/screens/setting/dev_screen.py +++ b/screens/setting/dev_screen.py @@ -17,6 +17,7 @@ def build_dev_screen(on_exit) -> QWidget: layout.addWidget(_build_persist_toggle()) layout.addWidget(_build_sound_toggles()) + layout.addWidget(_build_mock_devices_toggle()) hdr = QHBoxLayout() hdr.setContentsMargins(0, 0, 0, 0) @@ -164,6 +165,48 @@ def _dev_flag_path() -> Path: return Path(build_info.__file__).resolve().parent / "dev_mode_enable" +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( "Подтверждение", diff --git a/services/bluetooth_service.py b/services/bluetooth_service.py index 482b834..62ec303 100644 --- a/services/bluetooth_service.py +++ b/services/bluetooth_service.py @@ -11,7 +11,11 @@ from PySide6.QtCore import QObject, Signal import build_info -MOCK_PAIRED_DEVICED = True + +def _is_mock_devices_enabled() -> bool: + """Проверить, включён ли режим мок-устройств.""" + flag_path = Path(build_info.__file__).resolve().parent / "mock_devices_enable" + return flag_path.exists() @dataclass @@ -50,7 +54,7 @@ class BluetoothService(QObject): devices.append(BluetoothDevice(mac=mac, name=name)) # DEBUG: мок устройств для тестирования лимита - if MOCK_PAIRED_DEVICED: + if _is_mock_devices_enabled(): real_count = len(devices) missing = build_info.BLUETOOTH_MAX_PAIRED_DEVICES - real_count for i in range(missing): diff --git a/themes/day.py b/themes/day.py index 19a212f..6c93baf 100644 --- a/themes/day.py +++ b/themes/day.py @@ -150,6 +150,9 @@ QScrollArea > QWidget > QWidget { background: transparent; } #BluetoothList::item:hover { background: transparent; border: 0; outline: 0; } #BluetoothList::item:selected { background: transparent; border: 0; outline: 0; } #BluetoothList::item:focus { background: transparent; border: 0; outline: 0; } +#BluetoothList::scroll-bar { width: 0px; background: transparent; } +#BluetoothList::scroll-bar:vertical { width: 0px; } +#BluetoothList::scroll-bar:horizontal { height: 0px; } #BluetoothDeviceCard { background: #FFFFFF; border-radius: 14px; diff --git a/themes/night.py b/themes/night.py index a7be749..cbc04d0 100644 --- a/themes/night.py +++ b/themes/night.py @@ -140,6 +140,9 @@ QScrollArea > QWidget > QWidget { background: transparent; } #BluetoothList::item:hover { background: transparent; border: 0; outline: 0; } #BluetoothList::item:selected { background: transparent; border: 0; outline: 0; } #BluetoothList::item:focus { background: transparent; border: 0; outline: 0; } +#BluetoothList::scroll-bar { width: 0px; background: transparent; } +#BluetoothList::scroll-bar:vertical { width: 0px; } +#BluetoothList::scroll-bar:horizontal { height: 0px; } #BluetoothDeviceCard { background: #141A22; border-radius: 14px;