fix: 概率性出现蓝牙开关关闭的情况下,蓝牙选项依然存在,而且刷新按钮还在刷新

删掉蓝牙设置的布局

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 <fanpengcheng@uniontech.com>
Reviewed-by: <mailman@uniontech.com>
Reviewed-by: wangwei <wangwei@uniontech.com>
Tested-by: <mailman@uniontech.com>
This commit is contained in:
yexin 2020-08-25 18:44:16 +08:00
parent ae30c4593b
commit 99f76ab8b9
2 changed files with 29 additions and 30 deletions

View File

@ -97,7 +97,7 @@ BluetoothApplet::BluetoothApplet(QWidget *parent)
m_centrealLayout->addLayout(appletNameLayout); m_centrealLayout->addLayout(appletNameLayout);
m_centrealLayout->addWidget(m_line); m_centrealLayout->addWidget(m_line);
m_centrealLayout->addLayout(m_adapterLayout); m_centrealLayout->addLayout(m_adapterLayout);
m_centrealLayout->addLayout(m_menueLayout); m_centrealLayout->addWidget(m_openControlCenter);
m_centralWidget->setLayout(m_centrealLayout); m_centralWidget->setLayout(m_centrealLayout);
m_centralWidget->setFixedWidth(POPUPWIDTH); m_centralWidget->setFixedWidth(POPUPWIDTH);
m_centralWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); m_centralWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
@ -245,17 +245,15 @@ void BluetoothApplet::updateView()
isPowered = true; isPowered = true;
itemCount += adapterItem->deviceCount(); itemCount += adapterItem->deviceCount();
} }
if (adapterItem->connectedDevsName().size()) if (adapterItem->connectedDevsName().size()) {
isAdapterConnected = false; isAdapterConnected = false;
}
} }
} }
m_openControlCenter->setVisible(isPowered); m_openControlCenter->setVisible(isPowered);
if (isAdapterConnected) { if (isPowered) {
m_menueLayout->addWidget(m_openControlCenter);
contentHeight += ITEMHEIGHT; contentHeight += ITEMHEIGHT;
} else }
m_menueLayout->removeWidget(m_openControlCenter);
int adaptersCnt = m_adapterItems.size(); int adaptersCnt = m_adapterItems.size();
if (adaptersCnt > 1) { if (adaptersCnt > 1) {

View File

@ -94,30 +94,31 @@ AdaptersManager::AdaptersManager(QObject *parent)
void AdaptersManager::setAdapterPowered(const Adapter *adapter, const bool &powered) void AdaptersManager::setAdapterPowered(const Adapter *adapter, const bool &powered)
{ {
if (adapter) { if (!adapter)
QDBusObjectPath path(adapter->id()); return;
QDBusPendingCall call = m_bluetoothInter->SetAdapterPowered(path, powered);
if (powered) { QDBusObjectPath path(adapter->id());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); QDBusPendingCall call = m_bluetoothInter->SetAdapterPowered(path, powered);
connect(watcher, &QDBusPendingCallWatcher::finished, [this, call, adapter] {
if (!call.isError()) { if (powered) {
QDBusObjectPath dPath(adapter->id()); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
m_bluetoothInter->SetAdapterDiscoverableTimeout(dPath, 60 * 5); connect(watcher, &QDBusPendingCallWatcher::finished, [this, call, adapter] {
m_bluetoothInter->SetAdapterDiscoverable(dPath, true); if (!call.isError()) {
m_bluetoothInter->RequestDiscovery(dPath); QDBusObjectPath dPath(adapter->id());
} else { m_bluetoothInter->SetAdapterDiscoverableTimeout(dPath, 60 * 5);
qWarning() << call.error().message(); m_bluetoothInter->SetAdapterDiscoverable(dPath, true);
} m_bluetoothInter->RequestDiscovery(dPath);
}); } else {
} else { qWarning() << call.error().message();
QDBusPendingCall call = m_bluetoothInter->ClearUnpairedDevice(); }
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); });
connect(watcher, &QDBusPendingCallWatcher::finished, [ = ] { } else {
if (call.isError()) QDBusPendingCall call = m_bluetoothInter->ClearUnpairedDevice();
qWarning() << call.error().message(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
}); connect(watcher, &QDBusPendingCallWatcher::finished, [ = ] {
} if (call.isError())
qWarning() << call.error().message();
});
} }
} }