Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,13 @@ void BluetoothAdapterItem::initConnect()
});

connect(m_adapter, &Adapter::poweredChanged, this, [ = ](bool state) {
initData();
if (state) {
// Initialize device list when bluetooth is powered on
initData();
} else {
// Clear device list when bluetooth is powered off
clearDeviceList();
}
m_refreshBtn->setVisible(state);
m_myDeviceWidget->setVisible(m_myDeviceModel->rowCount() > 0 && state);
m_otherDeviceListView->setVisible(state && (m_otherDeviceControlWidget->isExpand() || m_myDeviceModel->rowCount() < 1));
Expand All @@ -438,11 +444,8 @@ void BluetoothAdapterItem::initConnect()
});
connect(m_adapterStateBtn, &DSwitchButton::clicked, this, [ = ](bool state) {
m_adapterSwitchEnabled = state;
qDeleteAll(m_deviceItems);
m_deviceItems.clear();
m_myDeviceModel->clear();
clearDeviceList();
m_myDeviceWidget->setVisible(false);
m_otherDeviceModel->clear();
m_otherDeviceListView->setVisible(false);
m_adapterStateBtn->setEnabled(false);
m_refreshBtn->setVisible(state);
Expand Down Expand Up @@ -550,3 +553,11 @@ void BluetoothAdapterItem::updateMyDeviceLabelTheme()
palette.setColor(QPalette::WindowText, textColor);
DPaletteHelper::instance()->setPalette(m_myDeviceLabel, palette);
}

void BluetoothAdapterItem::clearDeviceList()
{
qDeleteAll(m_deviceItems);
m_deviceItems.clear();
m_myDeviceModel->clear();
m_otherDeviceModel->clear();
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public slots:
void initConnect();
void setUnnamedDevicesVisible(bool isShow);
void updateMyDeviceLabelTheme();
void clearDeviceList();

Adapter *m_adapter;
SettingLabel *m_adapterLabel;
Expand Down