Skip to content

Commit

Permalink
fix: 通过dde-dock版本判断任务栏插件的处理方式
Browse files Browse the repository at this point in the history
通过dde-dock版本判断任务栏插件的处理方式

Log: 通过dde-dock版本判断任务栏插件的处理方式
  • Loading branch information
feeengli committed Sep 13, 2023
1 parent b5f1287 commit c248cd3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 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
26 changes: 13 additions & 13 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()

Check warning on line 81 in deepin-system-monitor-plugin/gui/monitor_plugin.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'pluginStateSwitched' is never used.
{
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)

Check warning on line 98 in deepin-system-monitor-plugin/gui/monitor_plugin.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'itemTipsWidget' is never used.
{
Expand Down Expand Up @@ -284,6 +282,7 @@ void MonitorPlugin::loadPlugin()
displayModeChanged(displayMode());
}

#ifndef DDE_DOCK_NEW_VERSION
void MonitorPlugin::refreshPluginItemsVisible()
{
if (pluginIsDisable()) {
Expand All @@ -296,6 +295,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 c248cd3

Please sign in to comment.