From 44af20205aac634ad2b614b50174d25e3df7a522 Mon Sep 17 00:00:00 2001 From: fengshaoxiong Date: Wed, 24 Jun 2020 18:44:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(bluetooth):=20=E8=93=9D=E7=89=99=E5=85=B3?= =?UTF-8?q?=E9=97=AD1=E5=88=86=E9=92=9F=E5=90=8E=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=89=93=E5=BC=80=E5=90=8E=EF=BC=8C=E4=B8=8D=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E8=93=9D=E7=89=99=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 蓝牙重新打开后,需要根据是否需要扫描,触发扫描操作 Log: 解决蓝牙关闭1分钟后重新打开后,不刷新蓝牙设备问题 Bug: https://pms.uniontech.com/zentao/bug-view-35148.html --- plugins/bluetooth/bluetoothapplet.cpp | 8 ++++++++ plugins/bluetooth/bluetoothapplet.h | 1 + plugins/bluetooth/bluetoothitem.cpp | 2 ++ plugins/bluetooth/componments/adapteritem.cpp | 3 ++- plugins/bluetooth/componments/adapteritem.h | 2 ++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/bluetooth/bluetoothapplet.cpp b/plugins/bluetooth/bluetoothapplet.cpp index 2b9f14fa3..ee6eefa25 100644 --- a/plugins/bluetooth/bluetoothapplet.cpp +++ b/plugins/bluetooth/bluetoothapplet.cpp @@ -317,3 +317,11 @@ void BluetoothApplet::getDevieInitStatus(AdapterItem *item) break; } } + +void BluetoothApplet::setAdapterRefresh() +{ + for (AdapterItem *adapterItem : m_adapterItems) { + if (adapterItem) + adapterItem->refresh(); + } +} diff --git a/plugins/bluetooth/bluetoothapplet.h b/plugins/bluetooth/bluetoothapplet.h index 9274c5e2c..0972f1b0a 100644 --- a/plugins/bluetooth/bluetoothapplet.h +++ b/plugins/bluetooth/bluetoothapplet.h @@ -41,6 +41,7 @@ class BluetoothApplet : public QScrollArea public: explicit BluetoothApplet(QWidget *parent = nullptr); void setAdapterPowered(bool powered); + void setAdapterRefresh(); bool poweredInitState(); bool hasAadapter(); QStringList connectedDevsName(); diff --git a/plugins/bluetooth/bluetoothitem.cpp b/plugins/bluetooth/bluetoothitem.cpp index 90d4df57e..27beffaa7 100644 --- a/plugins/bluetooth/bluetoothitem.cpp +++ b/plugins/bluetooth/bluetoothitem.cpp @@ -68,6 +68,8 @@ QWidget *BluetoothItem::tipsWidget() QWidget *BluetoothItem::popupApplet() { + if (m_applet && m_applet->hasAadapter()) + m_applet->setAdapterRefresh(); return m_applet->hasAadapter() ? m_applet : nullptr; } diff --git a/plugins/bluetooth/componments/adapteritem.cpp b/plugins/bluetooth/componments/adapteritem.cpp index 873fcdf6f..717df94fa 100644 --- a/plugins/bluetooth/componments/adapteritem.cpp +++ b/plugins/bluetooth/componments/adapteritem.cpp @@ -49,7 +49,6 @@ AdapterItem::AdapterItem(AdaptersManager *adapterManager, Adapter *adapter, QWid m_switchItem->setTitle(adapter->name()); m_switchItem->setChecked(adapter->powered(),false); m_switchItem->setLoading(adapter->discover()); - m_adaptersManager->setAdapterPowered(m_adapter, adapter->powered()); m_deviceLayout->addWidget(m_switchItem); m_deviceLayout->addWidget(m_line); @@ -343,6 +342,8 @@ void AdapterItem::showDevices(bool powered) void AdapterItem::refresh() { + if (m_adapter->discover()) + return; m_adaptersManager->adapterRefresh(m_adapter); } diff --git a/plugins/bluetooth/componments/adapteritem.h b/plugins/bluetooth/componments/adapteritem.h index 7ac84a82a..8564f0d4d 100644 --- a/plugins/bluetooth/componments/adapteritem.h +++ b/plugins/bluetooth/componments/adapteritem.h @@ -60,6 +60,8 @@ private slots: void addDeviceItem(const Device *constDevice); void deviceChangeState(const Device::State state); void moveDeviceItem(Device::State state, DeviceItem *item); + +public slots: void refresh(); private: