mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
feat: 适配飞行模式
飞行模式开启时,应禁用蓝牙,飞行模式关闭后,取消禁用 Log: Influence: 飞行模块开启或关闭,需要禁用或启动蓝牙模块 Task: https://pms.uniontech.com/zentao/task-view-89206.html Change-Id: I1dbec5a1e02265d37f5d708276274c5e92811314
This commit is contained in:
parent
2af79235be
commit
a6c5c09efe
@ -92,7 +92,7 @@ const QString BluetoothItem::contextMenu() const
|
|||||||
shift["itemText"] = tr("Turn off");
|
shift["itemText"] = tr("Turn off");
|
||||||
else
|
else
|
||||||
shift["itemText"] = tr("Turn on");
|
shift["itemText"] = tr("Turn on");
|
||||||
shift["isActive"] = true;
|
shift["isActive"] = !m_applet->airplaneModeEnable();
|
||||||
items.push_back(shift);
|
items.push_back(shift);
|
||||||
|
|
||||||
QMap<QString, QVariant> settings;
|
QMap<QString, QVariant> settings;
|
||||||
|
@ -100,6 +100,8 @@ BluetoothApplet::BluetoothApplet(QWidget *parent)
|
|||||||
, m_mainLayout(new QVBoxLayout(this))
|
, m_mainLayout(new QVBoxLayout(this))
|
||||||
, m_contentLayout(new QVBoxLayout(m_contentWidget))
|
, m_contentLayout(new QVBoxLayout(m_contentWidget))
|
||||||
, m_seperator(new HorizontalSeperator(this))
|
, m_seperator(new HorizontalSeperator(this))
|
||||||
|
, m_airPlaneModeInter(new DBusAirplaneMode("com.deepin.daemon.AirplaneMode", "/com/deepin/daemon/AirplaneMode", QDBusConnection::systemBus(), this))
|
||||||
|
, m_airplaneModeEnable(false)
|
||||||
{
|
{
|
||||||
initUi();
|
initUi();
|
||||||
initConnect();
|
initConnect();
|
||||||
@ -235,6 +237,9 @@ void BluetoothApplet::initUi()
|
|||||||
m_mainLayout->setContentsMargins(0, 0, 0, 0);
|
m_mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
m_mainLayout->addWidget(m_scroarea);
|
m_mainLayout->addWidget(m_scroarea);
|
||||||
updateSize();
|
updateSize();
|
||||||
|
|
||||||
|
setAirplaneModeEnabled(m_airPlaneModeInter->enabled());
|
||||||
|
setDisabled(m_airPlaneModeInter->enabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BluetoothApplet::initConnect()
|
void BluetoothApplet::initConnect()
|
||||||
@ -252,6 +257,8 @@ void BluetoothApplet::initConnect()
|
|||||||
.call();
|
.call();
|
||||||
});
|
});
|
||||||
connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, this, &BluetoothApplet::updateIconTheme);
|
connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, this, &BluetoothApplet::updateIconTheme);
|
||||||
|
connect(m_airPlaneModeInter, &DBusAirplaneMode::EnabledChanged, this, &BluetoothApplet::setAirplaneModeEnabled);
|
||||||
|
connect(m_airPlaneModeInter, &DBusAirplaneMode::EnabledChanged, this, &BluetoothApplet::setDisabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -273,6 +280,14 @@ void BluetoothApplet::updateIconTheme()
|
|||||||
m_scroarea->setPalette(scroareaBackgroud);
|
m_scroarea->setPalette(scroareaBackgroud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BluetoothApplet::setAirplaneModeEnabled(bool enable)
|
||||||
|
{
|
||||||
|
if (m_airplaneModeEnable == enable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_airplaneModeEnable = enable;
|
||||||
|
}
|
||||||
|
|
||||||
void BluetoothApplet::updateSize()
|
void BluetoothApplet::updateSize()
|
||||||
{
|
{
|
||||||
int height = 0;
|
int height = 0;
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include <dtkwidget_global.h>
|
#include <dtkwidget_global.h>
|
||||||
|
|
||||||
|
#include <com_deepin_daemon_airplanemode.h>
|
||||||
|
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
|
|
||||||
@ -46,6 +48,8 @@ DWIDGET_END_NAMESPACE
|
|||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
|
using DBusAirplaneMode = com::deepin::daemon::AirplaneMode;
|
||||||
|
|
||||||
class SettingLabel : public QWidget
|
class SettingLabel : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -82,6 +86,8 @@ public:
|
|||||||
// 已连接蓝牙设备名称列表,用于获取鼠标悬浮在蓝牙插件上时tips显示内容
|
// 已连接蓝牙设备名称列表,用于获取鼠标悬浮在蓝牙插件上时tips显示内容
|
||||||
QStringList connectedDevicesName();
|
QStringList connectedDevicesName();
|
||||||
|
|
||||||
|
inline bool airplaneModeEnable() const { return m_airplaneModeEnable;}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void noAdapter();
|
void noAdapter();
|
||||||
void justHasAdapter();
|
void justHasAdapter();
|
||||||
@ -97,6 +103,7 @@ public slots:
|
|||||||
void onSetAdapterPower(Adapter *adapter, bool state);
|
void onSetAdapterPower(Adapter *adapter, bool state);
|
||||||
// 更新蓝牙适配器电源状态,用于更新任务栏蓝牙插件图标的显示状态
|
// 更新蓝牙适配器电源状态,用于更新任务栏蓝牙插件图标的显示状态
|
||||||
void updateBluetoothPowerState();
|
void updateBluetoothPowerState();
|
||||||
|
void setAirplaneModeEnabled(bool enable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initUi();
|
void initUi();
|
||||||
@ -116,6 +123,8 @@ private:
|
|||||||
|
|
||||||
QStringList m_connectDeviceName;
|
QStringList m_connectDeviceName;
|
||||||
QMap<QString, BluetoothAdapterItem *> m_adapterItems; // 所有蓝牙适配器
|
QMap<QString, BluetoothAdapterItem *> m_adapterItems; // 所有蓝牙适配器
|
||||||
|
DBusAirplaneMode *m_airPlaneModeInter;
|
||||||
|
bool m_airplaneModeEnable;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BLUETOOTHAPPLET_H
|
#endif // BLUETOOTHAPPLET_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user