feat: 任务栏飞行模式常驻,支持修改飞行模式状态,支持右键操作

任务栏飞行模式功能添加

Log: 任务栏飞行模式功能
Influence: 飞行模式
Task: https://pms.uniontech.com/bug-view-124385.html
Change-Id: I624a39086f4348bb09e6f9335d7e3f8204e56c99
This commit is contained in:
zengaoyuan 2022-05-09 10:56:08 +08:00 committed by wubw
parent bdbde848d0
commit cafc36493c
4 changed files with 29 additions and 5 deletions

View File

@ -47,7 +47,6 @@ AirplaneModeApplet::AirplaneModeApplet(QWidget *parent)
appletlayout->addWidget(m_switchBtn);
appletlayout->addSpacing(0);
setLayout(appletlayout);
connect(m_switchBtn, &DSwitchButton::checkedChanged, this, &AirplaneModeApplet::enableChanged);
}

View File

@ -109,7 +109,6 @@ void AirplaneModeItem::invokeMenuItem(const QString menuId, const bool checked)
Q_UNUSED(menuId);
Q_UNUSED(checked);
/* 控制中心暂未实现
if (menuId == SHIFT)
m_airplaneModeInter->Enable(!m_airplaneModeInter->enabled());
else if (menuId == SETTINGS)
@ -121,7 +120,6 @@ void AirplaneModeItem::invokeMenuItem(const QString menuId, const bool checked)
.arg(QString("network"))
.arg(QString("Airplane Mode"))
.call();
*/
}
void AirplaneModeItem::refreshIcon()

View File

@ -83,6 +83,31 @@ QWidget *AirplaneModePlugin::itemTipsWidget(const QString &itemKey)
return nullptr;
}
QWidget *AirplaneModePlugin::itemPopupApplet(const QString &itemKey)
{
if (itemKey == AIRPLANEMODE_KEY) {
return m_item->popupApplet();
}
return nullptr;
}
const QString AirplaneModePlugin::itemContextMenu(const QString &itemKey)
{
if (itemKey == AIRPLANEMODE_KEY) {
return m_item->contextMenu();
}
return QString();
}
void AirplaneModePlugin::invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked)
{
if (itemKey == AIRPLANEMODE_KEY) {
m_item->invokeMenuItem(menuId, checked);
}
}
int AirplaneModePlugin::itemSortKey(const QString &itemKey)
{
const QString key = QString("pos_%1_%2").arg(itemKey).arg(Dock::Efficient);
@ -114,12 +139,11 @@ void AirplaneModePlugin::onAirplaneEnableChanged(bool enable)
if (!m_proxyInter)
return;
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
if (enable) {
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
m_proxyInter->saveValue(this, STATE_KEY, true);
}
else {
m_proxyInter->itemRemoved(this, AIRPLANEMODE_KEY);
m_proxyInter->saveValue(this, STATE_KEY, false);
}
}

View File

@ -43,6 +43,9 @@ public:
bool pluginIsDisable() Q_DECL_OVERRIDE;
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
QWidget *itemTipsWidget(const QString &itemKey) Q_DECL_OVERRIDE;
QWidget *itemPopupApplet(const QString &itemKey) Q_DECL_OVERRIDE;
const QString itemContextMenu(const QString &itemKey) Q_DECL_OVERRIDE;
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) Q_DECL_OVERRIDE;
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;