update design bl
This commit is contained in:
parent
2c8977a532
commit
366e27afec
@ -98,20 +98,6 @@ class BluetoothDeviceCard(QFrame):
|
|||||||
self._connected = connected
|
self._connected = connected
|
||||||
self._update_status_indicator()
|
self._update_status_indicator()
|
||||||
|
|
||||||
def set_busy(self, busy: bool, action_text: str = ""):
|
|
||||||
"""Установить состояние выполнения действия."""
|
|
||||||
self._busy = busy
|
|
||||||
if busy:
|
|
||||||
self.setCursor(Qt.WaitCursor)
|
|
||||||
self.status_label.setText(action_text)
|
|
||||||
self.status_label.setStyleSheet("color: #fbbf24;") # янтарный для процесса
|
|
||||||
else:
|
|
||||||
self.setCursor(Qt.PointingHandCursor)
|
|
||||||
self._update_status_indicator()
|
|
||||||
# Обновляем стиль карточки
|
|
||||||
self.style().unpolish(self)
|
|
||||||
self.style().polish(self)
|
|
||||||
|
|
||||||
def is_busy(self) -> bool:
|
def is_busy(self) -> bool:
|
||||||
"""Проверить, выполняется ли действие."""
|
"""Проверить, выполняется ли действие."""
|
||||||
return self._busy
|
return self._busy
|
||||||
@ -254,9 +240,10 @@ 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, "Подключение...")
|
# Выделяем только активную карточку
|
||||||
|
self._set_card_active(mac, True, "Подключение...")
|
||||||
|
|
||||||
def do_connect():
|
def do_connect():
|
||||||
success = self._bt_service.connect_device(mac)
|
success = self._bt_service.connect_device(mac)
|
||||||
@ -275,9 +262,10 @@ 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, "Отключение...")
|
# Выделяем только активную карточку
|
||||||
|
self._set_card_active(mac, True, "Отключение...")
|
||||||
|
|
||||||
def do_disconnect():
|
def do_disconnect():
|
||||||
success = self._bt_service.disconnect_device(mac)
|
success = self._bt_service.disconnect_device(mac)
|
||||||
@ -303,9 +291,10 @@ class BluetoothScreen(QWidget):
|
|||||||
ok_object_name="ConfirmOkDanger",
|
ok_object_name="ConfirmOkDanger",
|
||||||
)
|
)
|
||||||
if dialog.exec() == ConfirmDialog.Accepted:
|
if dialog.exec() == ConfirmDialog.Accepted:
|
||||||
# Блокируем все карточки
|
# Блокируем все карточки (только клики)
|
||||||
self._set_all_cards_busy(True)
|
self._set_all_cards_busy(True)
|
||||||
device.set_busy(True, "Удаление...")
|
# Выделяем только активную карточку
|
||||||
|
self._set_card_active(mac, True, "Удаление...")
|
||||||
|
|
||||||
success = self._bt_service.remove_device(mac)
|
success = self._bt_service.remove_device(mac)
|
||||||
if success:
|
if success:
|
||||||
@ -314,22 +303,38 @@ class BluetoothScreen(QWidget):
|
|||||||
else:
|
else:
|
||||||
self.status.setText(f"Статус: ошибка удаления ({self._bt_service.last_error})")
|
self.status.setText(f"Статус: ошибка удаления ({self._bt_service.last_error})")
|
||||||
self._set_all_cards_busy(False)
|
self._set_all_cards_busy(False)
|
||||||
|
self._set_card_active(mac, False)
|
||||||
|
|
||||||
def _finish_action(self, mac: str):
|
def _finish_action(self, mac: str):
|
||||||
"""Завершить действие и обновить статус."""
|
"""Завершить действие и обновить статус."""
|
||||||
self._set_all_cards_busy(False)
|
self._set_all_cards_busy(False)
|
||||||
|
self._set_card_active(mac, False)
|
||||||
self.refresh_list()
|
self.refresh_list()
|
||||||
|
|
||||||
def _set_all_cards_busy(self, busy: bool):
|
def _set_all_cards_busy(self, busy: bool):
|
||||||
"""Установить состояние busy для всех карточек."""
|
"""Установить состояние busy для всех карточек (только блокировка кликов)."""
|
||||||
for card in self._cards.values():
|
for card in self._cards.values():
|
||||||
|
card._busy = busy
|
||||||
if busy:
|
if busy:
|
||||||
card.setProperty("selected", True)
|
card.setCursor(Qt.WaitCursor)
|
||||||
else:
|
else:
|
||||||
card.setProperty("selected", False)
|
card.setCursor(Qt.PointingHandCursor)
|
||||||
|
|
||||||
|
def _set_card_active(self, mac: str, active: bool, action_text: str = ""):
|
||||||
|
"""Установить активное состояние для конкретной карточки (визуальное выделение)."""
|
||||||
|
if mac not in self._cards:
|
||||||
|
return
|
||||||
|
card = self._cards[mac]
|
||||||
|
card.setProperty("selected", active)
|
||||||
card.style().unpolish(card)
|
card.style().unpolish(card)
|
||||||
card.style().polish(card)
|
card.style().polish(card)
|
||||||
|
|
||||||
|
if active and action_text:
|
||||||
|
card.status_label.setText(action_text)
|
||||||
|
card.status_label.setStyleSheet("color: #fbbf24;")
|
||||||
|
elif not active:
|
||||||
|
card._update_status_indicator()
|
||||||
|
|
||||||
def _update_card_status(self, mac: str):
|
def _update_card_status(self, mac: str):
|
||||||
"""Обновить статус на карточке устройства."""
|
"""Обновить статус на карточке устройства."""
|
||||||
if mac in self._cards:
|
if mac in self._cards:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user