Skip to content

Commit 479c52d

Browse files
committed
fix: clear bluetooth device list when adapter is powered off
When airplane mode is enabled, bluetooth is automatically turned off. However, the device list was not being cleared, causing residual device information to be displayed in the bluetooth plugin panel. This fix ensures that when the bluetooth adapter is powered off, all device items and models are properly cleared to prevent display issues. Log: clear bluetooth device list when adapter is powered off Pms: BUG-338867
1 parent b92f43d commit 479c52d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,16 @@ void BluetoothAdapterItem::initConnect()
428428
});
429429

430430
connect(m_adapter, &Adapter::poweredChanged, this, [ = ](bool state) {
431-
initData();
431+
if (state) {
432+
// Initialize device list when bluetooth is powered on
433+
initData();
434+
} else {
435+
// Clear device list when bluetooth is powered off
436+
qDeleteAll(m_deviceItems);
437+
m_deviceItems.clear();
438+
m_myDeviceModel->clear();
439+
m_otherDeviceModel->clear();
440+
}
432441
m_refreshBtn->setVisible(state);
433442
m_myDeviceWidget->setVisible(m_myDeviceModel->rowCount() > 0 && state);
434443
m_otherDeviceListView->setVisible(state && (m_otherDeviceControlWidget->isExpand() || m_myDeviceModel->rowCount() < 1));

0 commit comments

Comments
 (0)