From 99f76ab8b9019c625dadf125f14bd46c777ef6bb Mon Sep 17 00:00:00 2001 From: yexin Date: Tue, 25 Aug 2020 18:44:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A6=82=E7=8E=87=E6=80=A7=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E8=93=9D=E7=89=99=E5=BC=80=E5=85=B3=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E8=93=9D=E7=89=99?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E4=BE=9D=E7=84=B6=E5=AD=98=E5=9C=A8=EF=BC=8C?= =?UTF-8?q?=E8=80=8C=E4=B8=94=E5=88=B7=E6=96=B0=E6=8C=89=E9=92=AE=E8=BF=98?= =?UTF-8?q?=E5=9C=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删掉蓝牙设置的布局 Log: 概率性出现蓝牙开关关闭的情况下,蓝牙选项依然存在,而且刷新按钮还在刷新 Bug: https://pms.uniontech.com/zentao/bug-view-33367.html Change-Id: I471757cea51f0637c63c3774bb3cbbdcfff0d329 Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/2714 Reviewed-by: fanpengcheng Reviewed-by: Reviewed-by: wangwei Tested-by: --- plugins/bluetooth/bluetoothapplet.cpp | 12 ++--- .../bluetooth/componments/adaptersmanager.cpp | 47 ++++++++++--------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/plugins/bluetooth/bluetoothapplet.cpp b/plugins/bluetooth/bluetoothapplet.cpp index d9ebc7530..43d4a37b0 100644 --- a/plugins/bluetooth/bluetoothapplet.cpp +++ b/plugins/bluetooth/bluetoothapplet.cpp @@ -97,7 +97,7 @@ BluetoothApplet::BluetoothApplet(QWidget *parent) m_centrealLayout->addLayout(appletNameLayout); m_centrealLayout->addWidget(m_line); m_centrealLayout->addLayout(m_adapterLayout); - m_centrealLayout->addLayout(m_menueLayout); + m_centrealLayout->addWidget(m_openControlCenter); m_centralWidget->setLayout(m_centrealLayout); m_centralWidget->setFixedWidth(POPUPWIDTH); m_centralWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); @@ -245,17 +245,15 @@ void BluetoothApplet::updateView() isPowered = true; itemCount += adapterItem->deviceCount(); } - if (adapterItem->connectedDevsName().size()) + if (adapterItem->connectedDevsName().size()) { isAdapterConnected = false; + } } } - m_openControlCenter->setVisible(isPowered); - if (isAdapterConnected) { - m_menueLayout->addWidget(m_openControlCenter); + if (isPowered) { contentHeight += ITEMHEIGHT; - } else - m_menueLayout->removeWidget(m_openControlCenter); + } int adaptersCnt = m_adapterItems.size(); if (adaptersCnt > 1) { diff --git a/plugins/bluetooth/componments/adaptersmanager.cpp b/plugins/bluetooth/componments/adaptersmanager.cpp index 1f29f9275..623499a44 100644 --- a/plugins/bluetooth/componments/adaptersmanager.cpp +++ b/plugins/bluetooth/componments/adaptersmanager.cpp @@ -94,30 +94,31 @@ AdaptersManager::AdaptersManager(QObject *parent) void AdaptersManager::setAdapterPowered(const Adapter *adapter, const bool &powered) { - if (adapter) { - QDBusObjectPath path(adapter->id()); - QDBusPendingCall call = m_bluetoothInter->SetAdapterPowered(path, powered); + if (!adapter) + return; - if (powered) { - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); - connect(watcher, &QDBusPendingCallWatcher::finished, [this, call, adapter] { - if (!call.isError()) { - QDBusObjectPath dPath(adapter->id()); - m_bluetoothInter->SetAdapterDiscoverableTimeout(dPath, 60 * 5); - m_bluetoothInter->SetAdapterDiscoverable(dPath, true); - m_bluetoothInter->RequestDiscovery(dPath); - } else { - qWarning() << call.error().message(); - } - }); - } else { - QDBusPendingCall call = m_bluetoothInter->ClearUnpairedDevice(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); - connect(watcher, &QDBusPendingCallWatcher::finished, [ = ] { - if (call.isError()) - qWarning() << call.error().message(); - }); - } + QDBusObjectPath path(adapter->id()); + QDBusPendingCall call = m_bluetoothInter->SetAdapterPowered(path, powered); + + if (powered) { + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + connect(watcher, &QDBusPendingCallWatcher::finished, [this, call, adapter] { + if (!call.isError()) { + QDBusObjectPath dPath(adapter->id()); + m_bluetoothInter->SetAdapterDiscoverableTimeout(dPath, 60 * 5); + m_bluetoothInter->SetAdapterDiscoverable(dPath, true); + m_bluetoothInter->RequestDiscovery(dPath); + } else { + qWarning() << call.error().message(); + } + }); + } else { + QDBusPendingCall call = m_bluetoothInter->ClearUnpairedDevice(); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + connect(watcher, &QDBusPendingCallWatcher::finished, [ = ] { + if (call.isError()) + qWarning() << call.error().message(); + }); } }