mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix: 热插拔无线网卡或蓝牙设备后,飞行模式未同步
热插拔后监听网络变化信号,同步飞行模式 Log: 同步飞行模式 Influence: 飞行模式 Task: https://pms.uniontech.com/bug-view-148383.html Change-Id: If1b9a99c8b91b5b5b99c22cf8294f0735b994a2a
This commit is contained in:
parent
3ec6ffffda
commit
7a75c3492b
@ -47,6 +47,12 @@ void AirplaneModePlugin::init(PluginProxyInterface *proxyInter)
|
||||
{
|
||||
m_proxyInter = proxyInter;
|
||||
|
||||
m_networkInter = new NetworkInter("com.deepin.daemon.Network", "/com/deepin/daemon/Network", QDBusConnection::sessionBus(), this);
|
||||
connect(m_networkInter, &NetworkInter::WirelessAccessPointsChanged, this, &AirplaneModePlugin::onWirelessAccessPointsOrAdapterChange);
|
||||
|
||||
m_bluetoothInter = new BluetoothInter("com.deepin.daemon.Bluetooth", "/com/deepin/daemon/Bluetooth", QDBusConnection::sessionBus(), this);
|
||||
connect(m_bluetoothInter, &BluetoothInter::AdapterAdded, this, &AirplaneModePlugin::onWirelessAccessPointsOrAdapterChange);
|
||||
connect(m_bluetoothInter, &BluetoothInter::AdapterRemoved, this, &AirplaneModePlugin::onWirelessAccessPointsOrAdapterChange);
|
||||
|
||||
if (!pluginIsDisable()) {
|
||||
if (supportAirplaneMode()) {
|
||||
@ -154,6 +160,15 @@ void AirplaneModePlugin::onAirplaneEnableChanged(bool enable)
|
||||
}
|
||||
}
|
||||
|
||||
void AirplaneModePlugin::onWirelessAccessPointsOrAdapterChange()
|
||||
{
|
||||
if (!supportAirplaneMode()) {
|
||||
m_proxyInter->itemRemoved(this, AIRPLANEMODE_KEY);
|
||||
} else {
|
||||
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
bool AirplaneModePlugin::supportAirplaneMode() const
|
||||
{
|
||||
// 蓝牙和无线网络,只要有其中一个就允许显示飞行模式
|
||||
@ -185,6 +200,7 @@ bool AirplaneModePlugin::supportAirplaneMode() const
|
||||
QDBusConnection::systemBus());
|
||||
if (deviceInter.isValid()) {
|
||||
QVariant reply = deviceInter.property("DeviceType");
|
||||
// 2 NM_DEVICE_TYPE_WIFI
|
||||
if (2 == reply.toUInt()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -24,6 +24,11 @@
|
||||
#define AIRPLANEMODEPLUGIN_H
|
||||
|
||||
#include "pluginsiteminterface.h"
|
||||
#include "com_deepin_daemon_network.h"
|
||||
#include "com_deepin_daemon_bluetooth.h"
|
||||
|
||||
using NetworkInter = com::deepin::daemon::Network;
|
||||
using BluetoothInter = com::deepin::daemon::Bluetooth;
|
||||
|
||||
class AirplaneModeItem;
|
||||
class AirplaneModePlugin : public QObject, PluginsItemInterface
|
||||
@ -56,9 +61,12 @@ private:
|
||||
public slots:
|
||||
void refreshAirplaneEnableState();
|
||||
void onAirplaneEnableChanged(bool enable);
|
||||
void onWirelessAccessPointsOrAdapterChange();
|
||||
|
||||
private:
|
||||
AirplaneModeItem *m_item;
|
||||
NetworkInter *m_networkInter;
|
||||
BluetoothInter *m_bluetoothInter;
|
||||
};
|
||||
|
||||
#endif // AIRPLANEMODEPLUGIN_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user