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(); + }); } }