Skip to content

Commit 37957fa

Browse files
committed
feat: adapt dock plugins for Treeland control center activation
Replace direct D-Bus calls to control center with XdgActivation-based process launching to support Treeland's activation protocol. This change updates multiple dock plugins (airplane mode, bluetooth, brightness, datetime, dnd mode, eye comfort, keyboard, media, notification, onboard, power, shutdown, sound, wireless casting) to use `dde-am` launcher with XDG activation tokens instead of `DDBusSender` for opening control center pages. Log: Switch dock plugin settings actions to use XdgActivation protocol for Treeland compatibility Influence: 1. Test each affected plugin's settings button opens correct control center page 2. Verify activation token is properly passed when available 3. Test with and without token support to ensure fallback behavior 4. Verify all existing D-Bus call replacements work correctly with dde- am 5. Test airplane mode settings opens network/airplaneMode page 6. Test bluetooth settings opens device/bluetooth page 7. Test brightness settings opens display page 8. Test all other plugins (datetime, dnd mode, eye comfort, keyboard, notification, power, shutdown, sound) open their respective pages 9. Verify no regression in existing plugin functionality feat: 适配 Treeland 的托盘插件控制中心激活方式 将直接通过 D-Bus 调用控制中心的方式替换为基于 XdgActivation 的进程启 动方式,以支持 Treeland 的激活协议。此更改更新了多个 dock 插件(飞行 模式、蓝牙、亮度、日期时间、勿扰模式、护眼、键盘、媒体、通知、虚拟键 盘、电源、关机、声音、投屏),使用 `dde-am` 启动器配合 XDG 激活令牌替代 `DDBusSender` 来打开控制中心页面。 Log: 切换托盘插件设置操作使用 XdgActivation 协议以兼容 Treeland Influence: 1. 测试每个受影响插件的设置按钮是否正确打开对应的控制中心页面 2. 验证激活令牌在可用时能够正确传递 3. 测试有令牌和无令牌的情况,确保降级行为正常 4. 验证所有替换 D-Bus 调用的地方都能通过 dde-am 正常工作 5. 测试飞行模式设置打开 network/airplaneMode 页面 6. 测试蓝牙设置打开 device/bluetooth 页面 7. 测试亮度设置打开 display 页面 8. 测试其他插件(日期时间、勿扰模式、护眼、键盘、通知、电源、关机、声 音)各自的页面 9. 验证现有插件功能没有回归
1 parent 95ad359 commit 37957fa

30 files changed

Lines changed: 239 additions & 158 deletions

File tree

plugins/dde-dock/airplane-mode/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
# SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
#
33
# SPDX-License-Identifier: CC0-1.0
44

@@ -64,6 +64,7 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE
6464
Qt${QT_VERSION_MAJOR}::DBus
6565
Qt${QT_VERSION_MAJOR}::Widgets
6666
Qt${QT_VERSION_MAJOR}::Svg
67+
dockpluginmanager-interface
6768
)
6869

6970
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/system-trays)

plugins/dde-dock/airplane-mode/airplanemodeitem.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2020 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -7,13 +7,15 @@
77
#include "constants.h"
88
#include "tipswidget.h"
99

10-
#include <DDBusSender>
10+
#include "xdgactivation.h"
11+
1112
#include <DGuiApplicationHelper>
1213

1314
#include <QDBusConnection>
1415
#include <QIcon>
1516
#include <QJsonDocument>
1617
#include <QPainter>
18+
#include <QProcess>
1719
#include <QVBoxLayout>
1820

1921
DGUI_USE_NAMESPACE
@@ -117,13 +119,16 @@ void AirplaneModeItem::invokeMenuItem(const QString menuId, const bool checked)
117119
if (menuId == SHIFT) {
118120
AMC_PTR->toggle();
119121
} else if (menuId == SETTINGS) {
120-
DDBusSender()
121-
.service("org.deepin.dde.ControlCenter1")
122-
.interface("org.deepin.dde.ControlCenter1")
123-
.path("/org/deepin/dde/ControlCenter1")
124-
.method(QString("ShowPage"))
125-
.arg(QString("network/airplaneMode"))
126-
.call();
122+
auto *activation = new tray::XdgActivation(this);
123+
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
124+
QStringList args {"--by-user", "org.deepin.dde.control-center"};
125+
if (!token.isEmpty())
126+
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
127+
args << "--" << "-p" << "network/airplaneMode";
128+
QProcess::startDetached("dde-am", args);
129+
activation->deleteLater();
130+
}, Qt::SingleShotConnection);
131+
activation->requestToken();
127132

128133
Q_EMIT requestHideApplet();
129134
}

plugins/dde-dock/bluetooth/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
# SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
#
33
# SPDX-License-Identifier: CC0-1.0
44

@@ -48,7 +48,8 @@ target_include_directories(${PLUGIN_NAME} PUBLIC
4848
../common
4949
../util
5050
../widgets
51-
componments)
51+
componments
52+
)
5253

5354
target_link_libraries(${PLUGIN_NAME} PRIVATE
5455
${XCB_EWMH_LIBRARIES}
@@ -58,6 +59,7 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE
5859
Qt${QT_VERSION_MAJOR}::Widgets
5960
Qt${QT_VERSION_MAJOR}::Svg
6061
Qt${QT_VERSION_MAJOR}::DBus
62+
dockpluginmanager-interface
6163
)
6264

6365
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/system-trays)

plugins/dde-dock/bluetooth/bluetoothitem.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
#include "constants.h"
1111
#include "quickpanelwidget.h"
1212

13+
#include "xdgactivation.h"
14+
1315
#include <DApplication>
14-
#include <DDBusSender>
1516
#include <DGuiApplicationHelper>
1617

1718
#include <QPainter>
19+
#include <QProcess>
1820

1921
// menu actions
2022
#define SHIFT "shift"
@@ -126,13 +128,16 @@ void BluetoothItem::invokeMenuItem(const QString menuId, const bool checked)
126128
}
127129
m_applet->setAdapterPowered(!m_adapterPowered);
128130
} else if (menuId == SETTINGS) {
129-
DDBusSender()
130-
.service("org.deepin.dde.ControlCenter1")
131-
.interface("org.deepin.dde.ControlCenter1")
132-
.path("/org/deepin/dde/ControlCenter1")
133-
.method(QString("ShowPage"))
134-
.arg(QString("device/bluetooth"))
135-
.call();
131+
auto *activation = new tray::XdgActivation(this);
132+
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
133+
QStringList args {"--by-user", "org.deepin.dde.control-center"};
134+
if (!token.isEmpty())
135+
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
136+
args << "--" << "-p" << "device/bluetooth";
137+
QProcess::startDetached("dde-am", args);
138+
activation->deleteLater();
139+
}, Qt::SingleShotConnection);
140+
activation->requestToken();
136141
Q_EMIT requestHideApplet();
137142
}
138143
}

plugins/dde-dock/bluetooth/componments/bluetoothapplet.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
#include "plugins-logging-category.h"
1616
#include "touchscrollfilter.h"
1717

18-
#include <DDBusSender>
18+
#include "xdgactivation.h"
19+
1920
#include <DIconButton>
2021
#include <DLabel>
22+
#include <QProcess>
2123
#include <DListView>
2224
#include <DScrollArea>
2325
#include <DSwitchButton>
@@ -303,15 +305,17 @@ void BluetoothApplet::initConnect()
303305
updateSize();
304306
});
305307

306-
connect(m_airplaneModeLabel, &DTipLabel::linkActivated, this, [=] {
307-
DDBusSender()
308-
.service("org.deepin.dde.ControlCenter1")
309-
.path("/org/deepin/dde/ControlCenter1")
310-
.interface("org.deepin.dde.ControlCenter1")
311-
.method(QString("ShowPage"))
312-
.arg(QString("network"))
313-
.arg(QString("airplaneMode"))
314-
.call();
308+
connect(m_airplaneModeLabel, &DTipLabel::linkActivated, this, [this] {
309+
auto *activation = new tray::XdgActivation(this);
310+
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
311+
QStringList args {"--by-user", "org.deepin.dde.control-center"};
312+
if (!token.isEmpty())
313+
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
314+
args << "--" << "-p" << "network/airplaneMode";
315+
QProcess::startDetached("dde-am", args);
316+
activation->deleteLater();
317+
}, Qt::SingleShotConnection);
318+
activation->requestToken();
315319
Q_EMIT requestHideApplet();
316320
});
317321
}

plugins/dde-dock/brightness/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
# SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
#
33
# SPDX-License-Identifier: CC0-1.0
44

@@ -44,14 +44,14 @@ target_include_directories(${PLUGIN_NAME} PUBLIC
4444
../util
4545
../common
4646
)
47-
4847
target_link_libraries(${PLUGIN_NAME} PRIVATE
4948
Dtk${DTK_VERSION_MAJOR}::Core
5049
Dtk${DTK_VERSION_MAJOR}::Widget
5150
Qt${QT_VERSION_MAJOR}::Widgets
5251
Qt${QT_VERSION_MAJOR}::Svg
5352
Qt${QT_VERSION_MAJOR}::DBus
5453
Qt${QT_VERSION_MAJOR}::Concurrent
54+
dockpluginmanager-interface
5555
)
5656

5757
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins)

plugins/dde-dock/brightness/brightnessitem.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2020 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

55
#include "brightnessitem.h"
66
#include "constants.h"
77
#include "brightnessmodel.h"
88

9-
#include <DDBusSender>
9+
#include "xdgactivation.h"
10+
1011
#include <DFontSizeManager>
1112
#include <DGuiApplicationHelper>
1213

1314
#include <QDBusConnection>
1415
#include <QIcon>
1516
#include <QJsonDocument>
1617
#include <QPainter>
18+
#include <QProcess>
1719
#include <QVBoxLayout>
1820

1921
DGUI_USE_NAMESPACE
@@ -79,14 +81,16 @@ void BrightnessItem::invokeMenuItem(const QString menuId, const bool checked)
7981
Q_UNUSED(checked);
8082

8183
if (menuId == SETTINGS) {
82-
DDBusSender()
83-
.service("org.deepin.dde.ControlCenter1")
84-
.interface("org.deepin.dde.ControlCenter1")
85-
.path("/org/deepin/dde/ControlCenter1")
86-
.method(QString("ShowPage"))
87-
.arg(QString("display"))
88-
.arg(QString(""))
89-
.call();
84+
auto *activation = new tray::XdgActivation(this);
85+
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
86+
QStringList args {"--by-user", "org.deepin.dde.control-center"};
87+
if (!token.isEmpty())
88+
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
89+
args << "--" << "-p" << "display";
90+
QProcess::startDetached("dde-am", args);
91+
activation->deleteLater();
92+
}, Qt::SingleShotConnection);
93+
activation->requestToken();
9094

9195
Q_EMIT requestHideApplet();
9296
}

plugins/dde-dock/common/jumpsettingbutton.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
// SPDX-FileCopyrightText: 2019 - 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

55
#include "jumpsettingbutton.h"
66
#include "dock-constants.h"
7+
#include "xdgactivation.h"
78

89
#include <QHBoxLayout>
10+
#include <QProcess>
911

1012
#include <DFontSizeManager>
1113
#include <DGuiApplicationHelper>
1214
#include <DPlatformTheme>
13-
#include <DDBusSender>
1415
#include <DPaletteHelper>
1516

1617
DWIDGET_USE_NAMESPACE
@@ -119,14 +120,16 @@ void JumpSettingButton::mouseReleaseEvent(QMouseEvent* event)
119120
if (underMouse()) {
120121
Q_EMIT clicked();
121122
if (m_autoShowPage && !m_fistPage.isEmpty()) {
122-
DDBusSender()
123-
.service("org.deepin.dde.ControlCenter1")
124-
.path("/org/deepin/dde/ControlCenter1")
125-
.interface("org.deepin.dde.ControlCenter1")
126-
.method(QString("ShowPage"))
127-
.arg(QString(m_fistPage))
128-
//.arg(QString(m_secondPage))
129-
.call();
123+
auto *activation = new tray::XdgActivation(this);
124+
connect(activation, &tray::XdgActivation::tokenReady, this, [this, activation](const QString &token) {
125+
QStringList args {"--by-user", "org.deepin.dde.control-center"};
126+
if (!token.isEmpty())
127+
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
128+
args << "--" << "-p" << m_fistPage;
129+
QProcess::startDetached("dde-am", args);
130+
activation->deleteLater();
131+
}, Qt::SingleShotConnection);
132+
activation->requestToken();
130133
Q_EMIT showPageRequestWasSended();
131134
}
132135
return;

plugins/dde-dock/datetime/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
# SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
#
33
# SPDX-License-Identifier: CC0-1.0
44

@@ -37,12 +37,12 @@ target_include_directories(${PLUGIN_NAME} PUBLIC
3737
../util
3838
calendar
3939
)
40-
4140
target_link_libraries(${PLUGIN_NAME} PRIVATE
4241
Dtk${DTK_VERSION_MAJOR}::Widget
4342
Qt${QT_VERSION_MAJOR}::Widgets
4443
Qt${QT_VERSION_MAJOR}::Svg
4544
Qt${QT_VERSION_MAJOR}::DBus
45+
dockpluginmanager-interface
4646
)
4747

4848
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins)

plugins/dde-dock/datetime/datetimeplugin.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -7,10 +7,13 @@
77
#include "plugins-logging-category.h"
88
#include "regionFormat.h"
99

10-
#include <DDBusSender>
10+
#include "xdgactivation.h"
11+
1112
#include <DConfig>
13+
#include <DDBusSender>
1214

1315
#include <QDebug>
16+
#include <QProcess>
1417

1518
Q_LOGGING_CATEGORY(DOCK_DATETIME, "org.deepin.dde.dock.datetime")
1619
Q_DECLARE_METATYPE(QMargins)
@@ -213,13 +216,16 @@ void DatetimePlugin::invokedMenuItem(const QString &itemKey, const QString &menu
213216
Q_UNUSED(checked)
214217

215218
if (menuId == "open") {
216-
DDBusSender()
217-
.service("org.deepin.dde.ControlCenter1")
218-
.interface("org.deepin.dde.ControlCenter1")
219-
.path("/org/deepin/dde/ControlCenter1")
220-
.method(QString("ShowModule"))
221-
.arg(QString("datetime"))
222-
.call();
219+
auto *activation = new tray::XdgActivation(this);
220+
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
221+
QStringList args {"--by-user", "org.deepin.dde.control-center"};
222+
if (!token.isEmpty())
223+
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
224+
args << "--" << "-p" << "datetime";
225+
QProcess::startDetached("dde-am", args);
226+
activation->deleteLater();
227+
}, Qt::SingleShotConnection);
228+
activation->requestToken();
223229
} else if (menuId == "settings") {
224230
const bool is24HourFormat = m_centralWidget->is24HourFormat();
225231
m_centralWidget->set24HourFormat(!is24HourFormat);

0 commit comments

Comments
 (0)