fix(bluetooth):right-click menu shows exception

右键菜单会出现在点击"打开蓝牙"菜单项后一直显示"打开蓝牙"(盘古集成测试不通过) task:21278

(cherry picked from commit 71f9cf3f857925f878cb10ed65eb5438e57d3586)
This commit is contained in:
zhaolong 2020-05-11 11:18:50 +08:00 committed by fpc_diesel
parent e55fb63e11
commit 364ceff32e
2 changed files with 15 additions and 3 deletions

View File

@ -196,7 +196,7 @@ void BluetoothApplet::addAdapter(Adapter *adapter)
auto adatpterItem = new AdapterItem(m_adaptersManager, adapter, this);
m_adapterItems[adapterId] = adatpterItem;
m_adapterLayout->addWidget(adatpterItem);
getDevieInitState(adatpterItem);
getDevieInitStatus(adatpterItem);
connect(adatpterItem, &AdapterItem::deviceStateChanged, this, &BluetoothApplet::onDeviceStateChanged);
connect(adatpterItem, &AdapterItem::powerChanged, this, &BluetoothApplet::onPowerChanged);
@ -261,11 +261,22 @@ void BluetoothApplet::updateView()
setVerticalScrollBarPolicy(itemCount <= 10 ? Qt::ScrollBarAlwaysOff : Qt::ScrollBarAlwaysOn);
}
void BluetoothApplet::getDevieInitState(AdapterItem *item)
void BluetoothApplet::getDevieInitStatus(AdapterItem *item)
{
if (!item)
return;
bool powered = item->isPowered();
for (AdapterItem *adapterItem : m_adapterItems) {
if (adapterItem != item) {
if (adapterItem->isPowered()) {
powered = true;
break;
}
}
}
emit powerChanged(powered);
Device::State deviceState = item->initDeviceState();
Device::State otherDeviceState = Device::StateUnavailable;
for (AdapterItem *adapterItem : m_adapterItems) {
@ -280,6 +291,7 @@ void BluetoothApplet::getDevieInitState(AdapterItem *item)
}
}
}
switch (deviceState) {
case Device::StateConnected:
emit deviceStateChanged(deviceState);

View File

@ -61,7 +61,7 @@ private slots:
private:
void updateView();
void getDevieInitState(AdapterItem *item);
void getDevieInitStatus(AdapterItem *item);
private:
HorizontalSeparator *m_line;