Skip to content

Commit 7a178d6

Browse files
feeenglideepin-bot[bot]
authored andcommitted
fix: 调整任务栏插件显示/隐藏控制
通过dde-dock版本判断任务栏插件的处理方式 dde-dock 6.0及以上版本应用不再自己控制插件的显示与隐藏 Log: 通过dde-dock版本判断任务栏插件的处理方式
1 parent b5f1287 commit 7a178d6

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

deepin-system-monitor-plugin/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pkg_check_modules(QGSettings REQUIRED gsettings-qt)
3030
pkg_check_modules(DdeDockInterface REQUIRED dde-dock)
3131

3232
if (DdeDockInterface_FOUND)
33-
message("dde-dock founded: ${VERSION_MAJOR}")
33+
message("dde-dock founded: ${DdeDockInterface_VERSION}")
3434
string(REGEX MATCH "^[0-9]" VERSION_MAJOR ${DdeDockInterface_VERSION})
3535
if (VERSION_MAJOR STREQUAL "6" OR VERSION_MAJOR STRGREATER "6")
3636
add_definitions(-DDDE_DOCK_NEW_VERSION)

deepin-system-monitor-plugin/gui/monitor_plugin.cpp

+22-21
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,32 @@ void MonitorPlugin::init(PluginProxyInterface *proxyInter)
6868

6969
QWidget *MonitorPlugin::itemWidget(const QString &itemKey)
7070
{
71-
if (!common::systemInfo().isOldVersion()) {
71+
#ifdef DDE_DOCK_NEW_VERSION
7272
// if (itemKey == "system-monitor")
7373
// return m_itemWidget;
74-
} else {
74+
#else
7575
if (itemKey == "system-monitor")
7676
return m_itemWidget;
77-
}
77+
#endif
7878
return nullptr;
7979
}
8080

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

87-
refreshPluginItemsVisible();
88-
}
87+
refreshPluginItemsVisible();
88+
#endif
8989
}
9090

91+
#ifndef DDE_DOCK_NEW_VERSION
9192
bool MonitorPlugin::pluginIsDisable()
9293
{
93-
if (!common::systemInfo().isOldVersion()) {
94-
return PluginsItemInterface::pluginIsDisable();
95-
} else {
96-
return !m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, false).toBool();
97-
}
94+
return !m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, false).toBool();
9895
}
96+
#endif
9997

10098
QWidget *MonitorPlugin::itemTipsWidget(const QString &itemKey)
10199
{
@@ -264,26 +262,28 @@ void MonitorPlugin::loadPlugin()
264262

265263
m_itemWidget = new MonitorPluginButtonWidget;
266264

265+
#ifdef DDE_DOCK_NEW_VERSION
266+
// 新版本dde-dock不需要应用自己判断是否显示插件,只添加即可
267+
m_proxyInter->itemAdded(this, pluginName());
268+
#else
267269
if (!m_isFirstInstall) {
268-
if (!common::systemInfo().isOldVersion()) {
270+
// 非初始状态
271+
if (m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, true).toBool()) {
269272
m_proxyInter->itemAdded(this, pluginName());
270273
} else {
271-
// 非初始状态
272-
if (m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, true).toBool()) {
273-
m_proxyInter->itemAdded(this, pluginName());
274-
} else {
275-
m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, false);
276-
m_proxyInter->itemRemoved(this, pluginName());
277-
}
274+
m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, false);
275+
m_proxyInter->itemRemoved(this, pluginName());
278276
}
279277
} else {
280278
m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, false);
281279
m_proxyInter->itemRemoved(this, pluginName());
282280
}
281+
#endif
283282

284283
displayModeChanged(displayMode());
285284
}
286285

286+
#ifndef DDE_DOCK_NEW_VERSION
287287
void MonitorPlugin::refreshPluginItemsVisible()
288288
{
289289
if (pluginIsDisable()) {
@@ -296,6 +296,7 @@ void MonitorPlugin::refreshPluginItemsVisible()
296296
m_proxyInter->itemAdded(this, pluginName());
297297
}
298298
}
299+
#endif
299300

300301
void MonitorPlugin::initPluginState()
301302
{

deepin-system-monitor-plugin/gui/monitor_plugin.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class MonitorPlugin : public QObject, PluginsItemInterface
8282
//!
8383
void pluginStateSwitched() Q_DECL_OVERRIDE;
8484

85+
#ifndef DDE_DOCK_NEW_VERSION
8586
//!
8687
//! \brief pluginIsAllowDisable 返回插件是否允许被禁用(默认不允许被禁用)
8788
//! \return
@@ -93,7 +94,7 @@ class MonitorPlugin : public QObject, PluginsItemInterface
9394
//! \return
9495
//!
9596
bool pluginIsDisable() Q_DECL_OVERRIDE;
96-
97+
#endif
9798
//!
9899
//! \brief itemTipsWidget 返回鼠标悬浮在插件主控件上时显示的提示框控件
99100
//! \param itemKey
@@ -164,10 +165,13 @@ private slots:
164165
//!
165166
void loadPlugin();
166167

168+
#ifndef DDE_DOCK_NEW_VERSION
167169
//!
168170
//! \brief refreshPluginItemsVisible 刷新插件项显示隐藏
169171
//!
170172
void refreshPluginItemsVisible();
173+
#endif
174+
171175
//!
172176
//! \brief initPluginState 初始化插件状态
173177
//!

0 commit comments

Comments
 (0)