fix: 无蓝牙和wifi模块,任务栏仍展示了飞行模式

添加过滤条件,只在有蓝牙或无线网络的机器显示飞行模式

Log: 有条件的显示飞行模式
Influence: 飞行模式
Task: https://pms.uniontech.com/bug-view-147945.html
Change-Id: I1ad1295d5be1d14afce5095ec7915cf009c9b64c
This commit is contained in:
zengaoyuan 2022-07-14 15:56:51 +08:00 committed by wubw
parent 459bc92e00
commit bd5ae48187

View File

@ -47,9 +47,6 @@ void AirplaneModePlugin::init(PluginProxyInterface *proxyInter)
{
m_proxyInter = proxyInter;
if (!pluginIsDisable())
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
bool hasBluetooth = false;
QDBusInterface inter("com.deepin.daemon.Bluetooth",
"/com/deepin/daemon/Bluetooth",
@ -58,9 +55,9 @@ void AirplaneModePlugin::init(PluginProxyInterface *proxyInter)
if (inter.isValid()) {
QDBusReply<QString> reply = inter.call("GetAdapters");
QString replyStr = reply.value();
replyStr = replyStr.replace("[", "");
replyStr = replyStr.replace("]", "");
if (!replyStr.isEmpty()) {
QJsonDocument json = QJsonDocument::fromJson(replyStr.toUtf8());
QJsonArray array = json.array();
if (array.size() > 0 && !array[0].toObject()["Path"].toString().isEmpty()) {
hasBluetooth = true;
}
}
@ -72,6 +69,12 @@ void AirplaneModePlugin::init(PluginProxyInterface *proxyInter)
hasWireless = true;
}
}
if (!pluginIsDisable()) {
if (hasBluetooth || hasWireless) {
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
}
}
// 蓝牙和无线网络,只要有其中一个就允许显示飞行模式
if (hasBluetooth || hasWireless) {
refreshAirplaneEnableState();