Skip to content

Commit 8ec4760

Browse files
committed
feat: add configurable show desktop feature
1. Added Enable_ShowDesktop configuration in dconfig to control show desktop area visibility 2. Implemented DConfig integration to read and monitor configuration changes 3. Added visible property and related signals in ShowDesktop class 4. Connected configuration changes to UI visibility updates 5. Added shouldVisible property in QML to reflect configuration state This change allows users to enable/disable the show desktop area through system settings while maintaining the existing functionality when enabled. The implementation uses DConfig for configuration management and properly propagates changes between backend and UI. feat: 添加可配置的显示桌面功能 1. 在dconfig中添加Enable_ShowDesktop配置项用于控制显示桌面区域的可见性 2. 实现DConfig集成以读取和监控配置变更 3. 在ShowDesktop类中添加visible属性和相关信号 4. 将配置变更连接到UI可见性更新 5. 在QML中添加shouldVisible属性以反映配置状态 此更改允许用户通过系统设置启用/禁用显示桌面区域,同时保留启用时的现有功 能。该实现使用DConfig进行配置管理,并正确地在后端和UI之间传播变更。 Pms: BUG-312457
1 parent 64a75f3 commit 8ec4760

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

panels/dock/dconfig/org.deepin.ds.dock.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@
8181
"description": "lock dock to prevent dragging resize",
8282
"permissions": "readwrite",
8383
"visibility": "private"
84+
},
85+
"EnableShowDesktop": {
86+
"value": true,
87+
"serial": 0,
88+
"flags": [],
89+
"name": "Enable ShowDesktop",
90+
"name[zh_CN]": "启用显示桌面区域",
91+
"description": "Enable or disable the show desktop area on the right side of the dock",
92+
"permissions": "readwrite",
93+
"visibility": "private"
8494
}
8595
}
8696
}

panels/dock/showdesktop/package/showdesktop.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ AppletItem {
1515
property bool useColumnLayout: Panel.position % 2
1616
property int dockSize: Panel.rootObject.dockItemMaxSize
1717
property int dockOrder: 30
18+
property bool shouldVisible: Applet.visible
1819
implicitWidth: useColumnLayout ? Panel.rootObject.dockSize : showDesktopWidth
1920
implicitHeight: useColumnLayout ? showDesktopWidth : Panel.rootObject.dockSize
2021

panels/dock/showdesktop/showdesktop.cpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,31 @@
1212
#include <QDBusInterface>
1313
#include <QLoggingCategory>
1414

15+
#include <DConfig>
16+
17+
DCORE_USE_NAMESPACE
18+
1519
Q_LOGGING_CATEGORY(showDesktop, "dde.shell.dock.showdesktop")
1620

1721
namespace dock {
1822

1923
ShowDesktop::ShowDesktop(QObject *parent)
2024
: DApplet(parent)
2125
, m_windowManager(nullptr)
26+
, m_dockConfig(nullptr)
27+
, m_visible(true)
2228
{
23-
29+
// 创建DConfig实例来读取dock配置
30+
m_dockConfig = DConfig::create("org.deepin.dde.shell", "org.deepin.ds.dock", QString(), this);
31+
32+
if (m_dockConfig) {
33+
// 监听配置变化
34+
connect(m_dockConfig, &DConfig::valueChanged, this, [this](const QString &key) {
35+
if (key == "EnableShowDesktop") {
36+
onEnableShowDesktopChanged();
37+
}
38+
});
39+
}
2440
}
2541

2642
bool ShowDesktop::load()
@@ -33,6 +49,12 @@ bool ShowDesktop::init()
3349
if (QStringLiteral("wayland") == QGuiApplication::platformName()) {
3450
m_windowManager = new TreelandWindowManager(this);
3551
}
52+
53+
// 从配置中读取初始的可见性状态
54+
if (m_dockConfig && m_dockConfig->isValid()) {
55+
m_visible = m_dockConfig->value("EnableShowDesktop", true).toBool();
56+
}
57+
3658
DApplet::init();
3759
return true;
3860
}
@@ -60,6 +82,28 @@ bool ShowDesktop::checkNeedShowDesktop()
6082
return false;
6183
}
6284

85+
bool ShowDesktop::visible() const
86+
{
87+
return m_visible;
88+
}
89+
90+
void ShowDesktop::setVisible(bool visible)
91+
{
92+
if (m_visible != visible) {
93+
m_visible = visible;
94+
Q_EMIT visibleChanged();
95+
}
96+
}
97+
98+
void ShowDesktop::onEnableShowDesktopChanged()
99+
{
100+
if (m_dockConfig && m_dockConfig->isValid()) {
101+
bool enabled = m_dockConfig->value("EnableShowDesktop", true).toBool();
102+
qDebug() << "onEnableShowDesktopChanged" << enabled;
103+
setVisible(enabled);
104+
}
105+
}
106+
63107
D_APPLET_CLASS(ShowDesktop)
64108
}
65109

panels/dock/showdesktop/showdesktop.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,36 @@
88
#include "dsglobal.h"
99
#include "treelandwindowmanager.h"
1010

11+
#include <DConfig>
12+
1113
namespace dock {
1214

1315
class ShowDesktop : public DS_NAMESPACE::DApplet
1416
{
1517
Q_OBJECT
18+
Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
19+
1620
public:
1721
explicit ShowDesktop(QObject *parent = nullptr);
1822
virtual bool init() override;
1923
virtual bool load() override;
2024

2125
Q_INVOKABLE void toggleShowDesktop();
2226
Q_INVOKABLE bool checkNeedShowDesktop();
27+
28+
Q_INVOKABLE bool visible() const;
29+
Q_INVOKABLE void setVisible(bool visible);
30+
31+
Q_SIGNALS:
32+
void visibleChanged();
33+
34+
private slots:
35+
void onEnableShowDesktopChanged();
2336

2437
private:
2538
TreelandWindowManager *m_windowManager;
39+
Dtk::Core::DConfig *m_dockConfig;
40+
bool m_visible;
2641
};
2742

2843
}

0 commit comments

Comments
 (0)