diff --git a/deepin-system-monitor-plugin/CMakeLists.txt b/deepin-system-monitor-plugin/CMakeLists.txt index 3504c0be..1fab2de1 100644 --- a/deepin-system-monitor-plugin/CMakeLists.txt +++ b/deepin-system-monitor-plugin/CMakeLists.txt @@ -72,7 +72,7 @@ qt5_add_translation(APP_QM_FILES ${APP_TS_FILES}) add_custom_target(PLUGIN_QMFILES ALL DEPENDS ${APP_QM_FILES}) INSTALL(FILES com.deepin.dde.dock.module.system-monitor.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas) -INSTALL(FILES com.deepin.system.monitor.plugin.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas) +#INSTALL(FILES com.deepin.system.monitor.plugin.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas) INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/dde-dock/plugins) #安装翻译文件 install(FILES ${APP_QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/deepin-system-monitor-plugin/translations) diff --git a/deepin-system-monitor-plugin/gui/monitor_plugin.cpp b/deepin-system-monitor-plugin/gui/monitor_plugin.cpp index 7afb301d..3c9e4134 100644 --- a/deepin-system-monitor-plugin/gui/monitor_plugin.cpp +++ b/deepin-system-monitor-plugin/gui/monitor_plugin.cpp @@ -33,10 +33,6 @@ MonitorPlugin::MonitorPlugin(QObject *parent) , m_quickPanelWidget(new QuickPanelWidget) #endif { - if (QGSettings::isSchemaInstalled("com.deepin.system.monitor.plugin")) { - m_settings = new QGSettings("com.deepin.system.monitor.plugin", "/com/deepin/system/monitor/plugin/", this); - } - connect(m_refershTimer, &QTimer::timeout, this, &MonitorPlugin::udpateTipsInfo); qInfo() <<__FUNCTION__ << __LINE__ << "[-MonitorPlugin-]" ; } @@ -94,8 +90,8 @@ QWidget *MonitorPlugin::itemWidget(const QString &itemKey) return m_quickPanelWidget; } #endif - if (itemKey == "system-monitor") - return m_itemWidget; + if (itemKey == "system-monitor") + return m_itemWidget; #endif return nullptr; } @@ -103,10 +99,17 @@ QWidget *MonitorPlugin::itemWidget(const QString &itemKey) void MonitorPlugin::pluginStateSwitched() { #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(); + const bool disabledNew = !pluginIsDisable(); + m_proxyInter->saveValue(this, "disabled", disabledNew); + if (disabledNew) { + m_proxyInter->itemRemoved(this, pluginName()); + } else { + if (!m_pluginLoaded) { + loadPlugin(); + return; + } + m_proxyInter->itemAdded(this, pluginName()); + } #endif } @@ -116,7 +119,7 @@ bool MonitorPlugin::pluginIsDisable() #ifdef USE_API_QUICKPANEL20 return false; #else - return !m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, false).toBool(); + return m_proxyInter->getValue(this, "disabled", true).toBool(); #endif } #endif @@ -283,8 +286,6 @@ void MonitorPlugin::loadPlugin() if (m_pluginLoaded) return; - initPluginState(); - m_pluginLoaded = true; m_dataTipsLabel.reset(new SystemMonitorTipsWidget); @@ -295,54 +296,11 @@ void MonitorPlugin::loadPlugin() m_itemWidget = new MonitorPluginButtonWidget; -#ifdef DDE_DOCK_NEW_VERSION - // 新版本dde-dock不需要应用自己判断是否显示插件,只添加即可 m_proxyInter->itemAdded(this, pluginName()); -#else - if (!m_isFirstInstall) { - // 非初始状态 - 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()); - } - } 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()) { - m_proxyInter->itemRemoved(this, pluginName()); - } else { - if (!m_pluginLoaded) { - loadPlugin(); - return; - } - m_proxyInter->itemAdded(this, pluginName()); - } -} -#endif - -void MonitorPlugin::initPluginState() -{ - if (m_settings == nullptr) - return; - if (m_settings->get("isfirstinstall").toBool()) { - m_isFirstInstall = true; - m_settings->set("isfirstinstall", false); - } else { - m_isFirstInstall = false; - } -} - void MonitorPlugin::calcCpuRate(qlonglong &totalCPU, qlonglong &availableCPU) { totalCPU = availableCPU = 0; diff --git a/deepin-system-monitor-plugin/gui/monitor_plugin.h b/deepin-system-monitor-plugin/gui/monitor_plugin.h index e65a9cd7..86b0cdfd 100644 --- a/deepin-system-monitor-plugin/gui/monitor_plugin.h +++ b/deepin-system-monitor-plugin/gui/monitor_plugin.h @@ -215,18 +215,6 @@ private slots: //! void loadPlugin(); -#ifndef DDE_DOCK_NEW_VERSION - //! - //! \brief refreshPluginItemsVisible 刷新插件项显示隐藏 - //! - void refreshPluginItemsVisible(); -#endif - - //! - //! \brief initPluginState 初始化插件状态 - //! - void initPluginState(); - //! //! \brief calcCpuRate 计算CPU占用率 //! \param totalCPU 总CPU占用率 @@ -273,7 +261,6 @@ private slots: bool m_pluginLoaded; MonitorPluginButtonWidget *m_itemWidget = nullptr; QScopedPointer m_dataTipsLabel; - QGSettings *m_settings; qlonglong m_down = 0; qlonglong m_upload = 0; @@ -284,8 +271,6 @@ private slots: QString startup; - bool m_isFirstInstall = false;//判断插件是否第一次安装 - QString m_cpuStr{"0.0"}; //转换后的cpu数据 QString m_memStr{"0.0"}; //转换后的mem数据 QString m_downloadStr{"0KB/s"}; //转换后的下载数据