From 6766b83e4e4101ac7c8ae67d66c41b2fb0684737 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 25 Dec 2023 15:17:51 +0800 Subject: [PATCH] fix: item hight error when turn off bluetooth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关闭蓝牙后还会收到上一个操作的设备扫描的新增信号 解决方案是关闭后不再响应这个信号 Issue: https://github.com/linuxdeepin/developer-center/issues/6033 --- plugins/bluetooth/componments/bluetoothadapteritem.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/bluetooth/componments/bluetoothadapteritem.cpp b/plugins/bluetooth/componments/bluetoothadapteritem.cpp index 6edeee994..de8a3517e 100644 --- a/plugins/bluetooth/componments/bluetoothadapteritem.cpp +++ b/plugins/bluetooth/componments/bluetoothadapteritem.cpp @@ -237,6 +237,10 @@ void BluetoothAdapterItem::updateIconTheme(DGuiApplicationHelper::ColorType type QSize BluetoothAdapterItem::sizeHint() const { + // 没有 item 就不去做一些无效的计算了,包括分割线的高度 + if (m_deviceListview->count() < 1) + return QSize(ItemWidth, m_adapterLabel->height()); + int visualHeight = 0; for (int i = 0; i < m_deviceListview->count(); i++) visualHeight += m_deviceListview->visualRect(m_deviceModel->index(i, 0)).height(); @@ -276,6 +280,10 @@ void BluetoothAdapterItem::initData() void BluetoothAdapterItem::onDeviceAdded(const Device *device) { + // 关闭蓝牙设备时,不再响应上一个扫描操作的新增的 device + if (!m_adapterStateBtn->isChecked()) + return; + int insertRow = 0; foreach (const auto item, m_deviceItems) { if (item->device()->connectState()) {