Skip to content

Commit

Permalink
fix: 调整任务栏插件显示/隐藏控制
Browse files Browse the repository at this point in the history
通过dde-dock版本判断任务栏插件的处理方式
dde-dock 6.0及以上版本应用不再自己控制插件的显示与隐藏

Log: 通过dde-dock版本判断任务栏插件的处理方式
  • Loading branch information
feeengli authored and deepin-bot[bot] committed Sep 14, 2023
1 parent b5f1287 commit 7a178d6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion deepin-system-monitor-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pkg_check_modules(QGSettings REQUIRED gsettings-qt)
pkg_check_modules(DdeDockInterface REQUIRED dde-dock)

if (DdeDockInterface_FOUND)
message("dde-dock founded: ${VERSION_MAJOR}")
message("dde-dock founded: ${DdeDockInterface_VERSION}")
string(REGEX MATCH "^[0-9]" VERSION_MAJOR ${DdeDockInterface_VERSION})
if (VERSION_MAJOR STREQUAL "6" OR VERSION_MAJOR STRGREATER "6")
add_definitions(-DDDE_DOCK_NEW_VERSION)
Expand Down
43 changes: 22 additions & 21 deletions deepin-system-monitor-plugin/gui/monitor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,32 @@ void MonitorPlugin::init(PluginProxyInterface *proxyInter)

QWidget *MonitorPlugin::itemWidget(const QString &itemKey)
{
if (!common::systemInfo().isOldVersion()) {
#ifdef DDE_DOCK_NEW_VERSION
// if (itemKey == "system-monitor")
// return m_itemWidget;
} else {
#else
if (itemKey == "system-monitor")
return m_itemWidget;
}
#endif
return nullptr;
}

void MonitorPlugin::pluginStateSwitched()
{
if (common::systemInfo().isOldVersion()) {
bool pluginState = !m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, false).toBool();
m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, pluginState);
#ifndef DDE_DOCK_NEW_VERSION
bool pluginState = !m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, false).toBool();
m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, pluginState);

refreshPluginItemsVisible();
}
refreshPluginItemsVisible();
#endif
}

#ifndef DDE_DOCK_NEW_VERSION
bool MonitorPlugin::pluginIsDisable()
{
if (!common::systemInfo().isOldVersion()) {
return PluginsItemInterface::pluginIsDisable();
} else {
return !m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, false).toBool();
}
return !m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, false).toBool();
}
#endif

QWidget *MonitorPlugin::itemTipsWidget(const QString &itemKey)
{
Expand Down Expand Up @@ -264,26 +262,28 @@ void MonitorPlugin::loadPlugin()

m_itemWidget = new MonitorPluginButtonWidget;

#ifdef DDE_DOCK_NEW_VERSION
// 新版本dde-dock不需要应用自己判断是否显示插件,只添加即可
m_proxyInter->itemAdded(this, pluginName());
#else
if (!m_isFirstInstall) {
if (!common::systemInfo().isOldVersion()) {
// 非初始状态
if (m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, true).toBool()) {
m_proxyInter->itemAdded(this, pluginName());
} else {
// 非初始状态
if (m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, true).toBool()) {
m_proxyInter->itemAdded(this, pluginName());
} else {
m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, false);
m_proxyInter->itemRemoved(this, pluginName());
}
m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, false);
m_proxyInter->itemRemoved(this, pluginName());
}
} else {
m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, false);
m_proxyInter->itemRemoved(this, pluginName());
}
#endif

displayModeChanged(displayMode());
}

#ifndef DDE_DOCK_NEW_VERSION
void MonitorPlugin::refreshPluginItemsVisible()
{
if (pluginIsDisable()) {
Expand All @@ -296,6 +296,7 @@ void MonitorPlugin::refreshPluginItemsVisible()
m_proxyInter->itemAdded(this, pluginName());
}
}
#endif

void MonitorPlugin::initPluginState()
{
Expand Down
6 changes: 5 additions & 1 deletion deepin-system-monitor-plugin/gui/monitor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class MonitorPlugin : public QObject, PluginsItemInterface
//!
void pluginStateSwitched() Q_DECL_OVERRIDE;

#ifndef DDE_DOCK_NEW_VERSION
//!
//! \brief pluginIsAllowDisable 返回插件是否允许被禁用(默认不允许被禁用)
//! \return
Expand All @@ -93,7 +94,7 @@ class MonitorPlugin : public QObject, PluginsItemInterface
//! \return
//!
bool pluginIsDisable() Q_DECL_OVERRIDE;

#endif
//!
//! \brief itemTipsWidget 返回鼠标悬浮在插件主控件上时显示的提示框控件
//! \param itemKey
Expand Down Expand Up @@ -164,10 +165,13 @@ private slots:
//!
void loadPlugin();

#ifndef DDE_DOCK_NEW_VERSION
//!
//! \brief refreshPluginItemsVisible 刷新插件项显示隐藏
//!
void refreshPluginItemsVisible();
#endif

//!
//! \brief initPluginState 初始化插件状态
//!
Expand Down

0 comments on commit 7a178d6

Please sign in to comment.