diff --git a/deepin-system-monitor-plugin/CMakeLists.txt b/deepin-system-monitor-plugin/CMakeLists.txt index a77f23ec..89884e36 100644 --- a/deepin-system-monitor-plugin/CMakeLists.txt +++ b/deepin-system-monitor-plugin/CMakeLists.txt @@ -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) diff --git a/deepin-system-monitor-plugin/gui/monitor_plugin.cpp b/deepin-system-monitor-plugin/gui/monitor_plugin.cpp index c4c57f9c..27ec3983 100644 --- a/deepin-system-monitor-plugin/gui/monitor_plugin.cpp +++ b/deepin-system-monitor-plugin/gui/monitor_plugin.cpp @@ -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) { @@ -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()) { @@ -296,6 +296,7 @@ void MonitorPlugin::refreshPluginItemsVisible() m_proxyInter->itemAdded(this, pluginName()); } } +#endif void MonitorPlugin::initPluginState() { diff --git a/deepin-system-monitor-plugin/gui/monitor_plugin.h b/deepin-system-monitor-plugin/gui/monitor_plugin.h index bf491825..e699d128 100644 --- a/deepin-system-monitor-plugin/gui/monitor_plugin.h +++ b/deepin-system-monitor-plugin/gui/monitor_plugin.h @@ -82,6 +82,7 @@ class MonitorPlugin : public QObject, PluginsItemInterface //! void pluginStateSwitched() Q_DECL_OVERRIDE; +#ifndef DDE_DOCK_NEW_VERSION //! //! \brief pluginIsAllowDisable 返回插件是否允许被禁用(默认不允许被禁用) //! \return @@ -93,7 +94,7 @@ class MonitorPlugin : public QObject, PluginsItemInterface //! \return //! bool pluginIsDisable() Q_DECL_OVERRIDE; - +#endif //! //! \brief itemTipsWidget 返回鼠标悬浮在插件主控件上时显示的提示框控件 //! \param itemKey @@ -164,10 +165,13 @@ private slots: //! void loadPlugin(); +#ifndef DDE_DOCK_NEW_VERSION //! //! \brief refreshPluginItemsVisible 刷新插件项显示隐藏 //! void refreshPluginItemsVisible(); +#endif + //! //! \brief initPluginState 初始化插件状态 //!