update design bl

This commit is contained in:
cheykrym 2026-04-01 01:06:40 +03:00
parent 6d96edbdfc
commit 2c8977a532

View File

@ -254,15 +254,18 @@ class BluetoothScreen(QWidget):
if card.is_busy(): if card.is_busy():
return return
# Блокируем все карточки # Сначала обновляем UI (через таймер чтобы Qt успел отрисовать)
self._set_all_cards_busy(True) self._set_all_cards_busy(True)
card.set_busy(True, "Подключение...") card.set_busy(True, "Подключение...")
success = self._bt_service.connect_device(mac) def do_connect():
if not success: success = self._bt_service.connect_device(mac)
self.status.setText(f"Статус: ошибка ({self._bt_service.last_error})") if not success:
self._settings.setValue("bluetooth/last_mac", mac) self.status.setText(f"Статус: ошибка ({self._bt_service.last_error})")
QTimer.singleShot(300, lambda: self._finish_action(mac)) self._settings.setValue("bluetooth/last_mac", mac)
QTimer.singleShot(500, lambda: self._finish_action(mac))
QTimer.singleShot(0, do_connect)
def _disconnect_device(self, mac: str): def _disconnect_device(self, mac: str):
"""Отключить устройство по MAC.""" """Отключить устройство по MAC."""
@ -272,16 +275,19 @@ class BluetoothScreen(QWidget):
if card.is_busy(): if card.is_busy():
return return
# Блокируем все карточки # Сначала обновляем UI (через таймер чтобы Qt успел отрисовать)
self._set_all_cards_busy(True) self._set_all_cards_busy(True)
card.set_busy(True, "Отключение...") card.set_busy(True, "Отключение...")
success = self._bt_service.disconnect_device(mac) def do_disconnect():
if not success: success = self._bt_service.disconnect_device(mac)
self.status.setText(f"Статус: ошибка ({self._bt_service.last_error})") if not success:
else: self.status.setText(f"Статус: ошибка ({self._bt_service.last_error})")
self.status.setText(f"Статус: отключено от {mac}") else:
QTimer.singleShot(300, lambda: self._finish_action(mac)) self.status.setText(f"Статус: отключено от {mac}")
QTimer.singleShot(500, lambda: self._finish_action(mac))
QTimer.singleShot(0, do_disconnect)
def _remove_device(self, mac: str): def _remove_device(self, mac: str):
"""Удалить устройство из списка сопряженных.""" """Удалить устройство из списка сопряженных."""