mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 修复飞行模式显示问题
1.gsettings不存在的情况下,或者值为true的情况下,飞行模式表现和需求一致。 2.如果gsettings值存在且为false,那么飞行模式始终不显示。 3.gsettings的值除手动修改外,不应有其他修改方式 Log: 修复飞行模式显示问题 Bug: https://pms.uniontech.com/zentao/bug-view-112804.html Influence: 任务栏-飞行模式插件-显示效果与需求保持一致 Change-Id: Iec07689cc77db8b80e6974d6171511a97e22671d
This commit is contained in:
parent
076f96f753
commit
406fb15ebf
@ -57,12 +57,7 @@ AirplaneModeItem::AirplaneModeItem(QWidget *parent)
|
|||||||
connect(m_airplaneModeInter, &DBusAirplaneMode::EnabledChanged, this, [this](bool enable) {
|
connect(m_airplaneModeInter, &DBusAirplaneMode::EnabledChanged, this, [this](bool enable) {
|
||||||
m_applet->setEnabled(enable);
|
m_applet->setEnabled(enable);
|
||||||
refreshIcon();
|
refreshIcon();
|
||||||
|
Q_EMIT airplaneEnableChanged(enable);
|
||||||
if (!enable || !Utils::SettingValue("com.deepin.dde.dock.module.airplane-mode", "/com/deepin/dde/dock/module/airplane-mode/", "enable", true).toBool())
|
|
||||||
emit removeItem();
|
|
||||||
else if (Utils::SettingValue("com.deepin.dde.dock.module.airplane-mode", "/com/deepin/dde/dock/module/airplane-mode/", "enable", true).toBool())
|
|
||||||
emit addItem();
|
|
||||||
|
|
||||||
updateTips();
|
updateTips();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -153,6 +148,11 @@ void AirplaneModeItem::updateTips()
|
|||||||
m_tipsLabel->setText(tr("Airplane mode disabled"));
|
m_tipsLabel->setText(tr("Airplane mode disabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AirplaneModeItem::airplaneEnable()
|
||||||
|
{
|
||||||
|
return m_airplaneModeInter->enabled();
|
||||||
|
}
|
||||||
|
|
||||||
void AirplaneModeItem::resizeEvent(QResizeEvent *e)
|
void AirplaneModeItem::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
QWidget::resizeEvent(e);
|
QWidget::resizeEvent(e);
|
||||||
|
@ -48,13 +48,14 @@ public:
|
|||||||
void refreshIcon();
|
void refreshIcon();
|
||||||
void updateTips();
|
void updateTips();
|
||||||
|
|
||||||
|
bool airplaneEnable();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
void paintEvent(QPaintEvent *e);
|
void paintEvent(QPaintEvent *e);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void removeItem();
|
void airplaneEnableChanged(bool enable);
|
||||||
void addItem();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Dock::TipsWidget *m_tipsLabel;
|
Dock::TipsWidget *m_tipsLabel;
|
||||||
|
@ -30,8 +30,7 @@ AirplaneModePlugin::AirplaneModePlugin(QObject *parent)
|
|||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_item(new AirplaneModeItem)
|
, m_item(new AirplaneModeItem)
|
||||||
{
|
{
|
||||||
connect(m_item, &AirplaneModeItem::removeItem, this, &AirplaneModePlugin::removePlugin);
|
connect(m_item, &AirplaneModeItem::airplaneEnableChanged, this, &AirplaneModePlugin::onAirplaneEnableChanged);
|
||||||
connect(m_item, &AirplaneModeItem::addItem, this, &AirplaneModePlugin::addPlugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString AirplaneModePlugin::pluginName() const
|
const QString AirplaneModePlugin::pluginName() const
|
||||||
@ -50,11 +49,15 @@ void AirplaneModePlugin::init(PluginProxyInterface *proxyInter)
|
|||||||
|
|
||||||
if (!pluginIsDisable())
|
if (!pluginIsDisable())
|
||||||
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
|
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
|
||||||
|
|
||||||
|
refreshAirplaneEnableState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirplaneModePlugin::pluginStateSwitched()
|
void AirplaneModePlugin::pluginStateSwitched()
|
||||||
{
|
{
|
||||||
m_proxyInter->saveValue(this, STATE_KEY, pluginIsDisable());
|
m_proxyInter->saveValue(this, STATE_KEY, pluginIsDisable());
|
||||||
|
|
||||||
|
refreshAirplaneEnableState();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AirplaneModePlugin::pluginIsDisable()
|
bool AirplaneModePlugin::pluginIsDisable()
|
||||||
@ -80,35 +83,6 @@ QWidget *AirplaneModePlugin::itemTipsWidget(const QString &itemKey)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *AirplaneModePlugin::itemPopupApplet(const QString &itemKey)
|
|
||||||
{
|
|
||||||
return nullptr; // 禁用左键点击功能
|
|
||||||
|
|
||||||
if (itemKey == AIRPLANEMODE_KEY) {
|
|
||||||
return m_item->popupApplet();
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString AirplaneModePlugin::itemContextMenu(const QString &itemKey)
|
|
||||||
{
|
|
||||||
return QString(); // 禁用右键菜单
|
|
||||||
|
|
||||||
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)
|
int AirplaneModePlugin::itemSortKey(const QString &itemKey)
|
||||||
{
|
{
|
||||||
const QString key = QString("pos_%1_%2").arg(itemKey).arg(Dock::Efficient);
|
const QString key = QString("pos_%1_%2").arg(itemKey).arg(Dock::Efficient);
|
||||||
@ -130,20 +104,24 @@ void AirplaneModePlugin::refreshIcon(const QString &itemKey)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirplaneModePlugin::removePlugin()
|
void AirplaneModePlugin::refreshAirplaneEnableState()
|
||||||
|
{
|
||||||
|
onAirplaneEnableChanged(m_item->airplaneEnable());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AirplaneModePlugin::onAirplaneEnableChanged(bool enable)
|
||||||
{
|
{
|
||||||
if (!m_proxyInter)
|
if (!m_proxyInter)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_proxyInter->itemRemoved(this, AIRPLANEMODE_KEY);
|
if (enable) {
|
||||||
m_proxyInter->saveValue(this, STATE_KEY, false);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirplaneModePlugin::addPlugin()
|
|
||||||
{
|
|
||||||
if (!m_proxyInter)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
|
|
||||||
m_proxyInter->saveValue(this, STATE_KEY, true);
|
|
||||||
}
|
|
||||||
|
@ -43,16 +43,13 @@ public:
|
|||||||
bool pluginIsDisable() Q_DECL_OVERRIDE;
|
bool pluginIsDisable() Q_DECL_OVERRIDE;
|
||||||
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
QWidget *itemTipsWidget(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;
|
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void removePlugin();
|
void refreshAirplaneEnableState();
|
||||||
void addPlugin();
|
void onAirplaneEnableChanged(bool enable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AirplaneModeItem *m_item;
|
AirplaneModeItem *m_item;
|
||||||
|
@ -22,15 +22,11 @@
|
|||||||
#include "systemtrayitem.h"
|
#include "systemtrayitem.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <com_deepin_daemon_airplanemode.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <xcb/xproto.h>
|
#include <xcb/xproto.h>
|
||||||
|
|
||||||
using DBusAirplaneMode = com::deepin::daemon::AirplaneMode;
|
|
||||||
Dock::Position SystemTrayItem::DockPosition = Dock::Position::Top;
|
Dock::Position SystemTrayItem::DockPosition = Dock::Position::Top;
|
||||||
QPointer<DockPopupWindow> SystemTrayItem::PopupWindow = nullptr;
|
QPointer<DockPopupWindow> SystemTrayItem::PopupWindow = nullptr;
|
||||||
|
|
||||||
@ -492,18 +488,6 @@ void SystemTrayItem::onGSettingsChanged(const QString &key) {
|
|||||||
|
|
||||||
if (m_gsettings && m_gsettings->keys().contains("enable")) {
|
if (m_gsettings && m_gsettings->keys().contains("enable")) {
|
||||||
const bool visible = m_gsettings->get("enable").toBool();
|
const bool visible = m_gsettings->get("enable").toBool();
|
||||||
|
|
||||||
// 飞行模式显示条件: gsettings为true且飞行模式已开启
|
|
||||||
DBusAirplaneMode airplaneBus("com.deepin.daemon.AirplaneMode",
|
|
||||||
"/com/deepin/daemon/AirplaneMode",
|
|
||||||
QDBusConnection::systemBus(),
|
|
||||||
this);
|
|
||||||
if (m_pluginInter && m_pluginInter->pluginName() == "airplane-mode" && !airplaneBus.enabled()) {
|
|
||||||
setVisible(false);
|
|
||||||
emit itemVisibleChanged(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setVisible(visible);
|
setVisible(visible);
|
||||||
emit itemVisibleChanged(visible);
|
emit itemVisibleChanged(visible);
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,9 @@
|
|||||||
#include "pluginsiteminterface.h"
|
#include "pluginsiteminterface.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <com_deepin_daemon_airplanemode.h>
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
using DBusAirplaneMode = com::deepin::daemon::AirplaneMode;
|
|
||||||
|
|
||||||
SystemTraysController::SystemTraysController(QObject *parent)
|
SystemTraysController::SystemTraysController(QObject *parent)
|
||||||
: AbstractPluginsController(parent)
|
: AbstractPluginsController(parent)
|
||||||
{
|
{
|
||||||
@ -40,20 +36,12 @@ void SystemTraysController::itemAdded(PluginsItemInterface * const itemInter, co
|
|||||||
{
|
{
|
||||||
QMap<PluginsItemInterface *, QMap<QString, QObject *>> &mPluginsMap = pluginsMap();
|
QMap<PluginsItemInterface *, QMap<QString, QObject *>> &mPluginsMap = pluginsMap();
|
||||||
|
|
||||||
SystemTrayItem *item = nullptr;
|
|
||||||
|
|
||||||
// check if same item added
|
// check if same item added
|
||||||
if (mPluginsMap.contains(itemInter))
|
if (mPluginsMap.contains(itemInter))
|
||||||
if (mPluginsMap[itemInter].contains(itemKey)) {
|
if (mPluginsMap[itemInter].contains(itemKey))
|
||||||
if (itemKey != "airplane-mode-key")
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
item = static_cast<SystemTrayItem *>(pluginItemAt(itemInter, itemKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!item)
|
|
||||||
item = new SystemTrayItem(itemInter, itemKey);
|
|
||||||
|
|
||||||
|
SystemTrayItem *item = new SystemTrayItem(itemInter, itemKey);
|
||||||
connect(item, &SystemTrayItem::itemVisibleChanged, this, [=] (bool visible){
|
connect(item, &SystemTrayItem::itemVisibleChanged, this, [=] (bool visible){
|
||||||
if (visible) {
|
if (visible) {
|
||||||
emit pluginItemAdded(itemKey, item);
|
emit pluginItemAdded(itemKey, item);
|
||||||
@ -65,22 +53,9 @@ void SystemTraysController::itemAdded(PluginsItemInterface * const itemInter, co
|
|||||||
|
|
||||||
mPluginsMap[itemInter][itemKey] = item;
|
mPluginsMap[itemInter][itemKey] = item;
|
||||||
|
|
||||||
if (itemInter->pluginName() == "airplane-mode") {
|
|
||||||
// 飞行模式显示条件: gsettings为true且飞行模式已开启
|
|
||||||
DBusAirplaneMode airplaneBus("com.deepin.daemon.AirplaneMode",
|
|
||||||
"/com/deepin/daemon/AirplaneMode",
|
|
||||||
QDBusConnection::systemBus(),
|
|
||||||
this);
|
|
||||||
if (!Utils::SettingValue(QString("com.deepin.dde.dock.module.airplane-mode"), QByteArray(), "enable", true).toBool() || !airplaneBus.enabled()) {
|
|
||||||
emit pluginItemRemoved(itemKey, item);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 隐藏的插件不加入到布局中
|
// 隐藏的插件不加入到布局中
|
||||||
if (Utils::SettingValue(QString("com.deepin.dde.dock.module.") + itemInter->pluginName(), QByteArray(), "enable", true).toBool()) {
|
if (Utils::SettingValue(QString("com.deepin.dde.dock.module.") + itemInter->pluginName(), QByteArray(), "enable", true).toBool())
|
||||||
emit pluginItemAdded(itemKey, item);
|
emit pluginItemAdded(itemKey, item);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTraysController::itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey)
|
void SystemTraysController::itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user