-
Notifications
You must be signed in to change notification settings - Fork 55
fix: 打开 dock 菜单时关闭启动器 #1399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: 打开 dock 菜单时关闭启动器 #1399
Conversation
在 dock 空白区域右键打开菜单时,启动器应该随其他弹窗一起关闭。 此修改通过 LauncherHelper 单例类实现启动器的关闭功能。 修改内容: - 新增 LauncherHelper 类,通过 DBus 调用启动器的 Hide 方法 - 在 dockpanel.cpp 中注册 LauncherHelper 为 QML 单例 - 在 MenuHelper.qml 中打开菜单时调用 LauncherHelper.hideLauncher() - 简化 MenuHelper.qml 中 aboutToHide 连接的处理方式 - 更新 CMakeLists.txt 添加新的源文件 PMS: BUG-323289 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Reviewer's GuideImplements a QML-accessible singleton helper to hide the launcher via D-Bus when opening the dock context menu, wires it into the dock panel and QML menu helper, and updates the build configuration accordingly. Sequence diagram for hiding launcher when opening dock menusequenceDiagram
actor User
participant DockPanel
participant MenuHelper_QML
participant LauncherHelper_singleton
participant DBus as DBus_SessionBus
participant LauncherService as dde_Launcher1
User->>DockPanel: Right_click_blank_dock_area()
DockPanel->>MenuHelper_QML: openMenu(menu)
MenuHelper_QML->>LauncherHelper_singleton: hideLauncher()
LauncherHelper_singleton->>DBus: call org.deepin.dde.Launcher1.Hide
DBus->>LauncherService: Hide
LauncherService-->>DBus: reply
DBus-->>LauncherHelper_singleton: QDBusMessage_reply
LauncherHelper_singleton-->>MenuHelper_QML: return
MenuHelper_QML->>MenuHelper_QML: menu.open()
Class diagram for new dock LauncherHelper singletonclassDiagram
class dock_LauncherHelper {
+static LauncherHelper* instance()
+void hideLauncher()
-LauncherHelper(QObject *parent)
-~LauncherHelper()
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 1 issue, and left some high level feedback:
- The new LauncherHelper class is declared inside the dock namespace, but dockpanel.cpp calls qmlRegisterSingletonType without a namespace qualifier; this likely won’t compile and should use dock::LauncherHelper (or a using declaration) consistently on both the type and the instance() call.
- Each call to MenuHelper.openMenu now does menu.aboutToHide.connect(...) without disconnecting previous connections, so opening the same menu multiple times will accumulate duplicate handlers; consider using a one-shot connection, checking isSignalConnected, or explicitly disconnecting before reconnecting.
- LauncherHelper::hideLauncher() creates a new QDBusInterface on every call; if this is invoked frequently, consider caching the interface as a member or using a helper to avoid repeated construction and validity checks.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new LauncherHelper class is declared inside the dock namespace, but dockpanel.cpp calls qmlRegisterSingletonType<LauncherHelper> without a namespace qualifier; this likely won’t compile and should use dock::LauncherHelper (or a using declaration) consistently on both the type and the instance() call.
- Each call to MenuHelper.openMenu now does menu.aboutToHide.connect(...) without disconnecting previous connections, so opening the same menu multiple times will accumulate duplicate handlers; consider using a one-shot connection, checking isSignalConnected, or explicitly disconnecting before reconnecting.
- LauncherHelper::hideLauncher() creates a new QDBusInterface on every call; if this is invoked frequently, consider caching the interface as a member or using a helper to avoid repeated construction and validity checks.
## Individual Comments
### Comment 1
<location> `panels/dock/dockpanel.cpp:64-66` </location>
<code_context>
+ // Use a separate namespace to avoid conflicts with auto-generated registrations
+ static bool registered = false;
+ if (!registered) {
+ qmlRegisterSingletonType<LauncherHelper>("org.deepin.ds.dock.helper", 1, 0, "LauncherHelper",
+ [](QQmlEngine *, QJSEngine *) -> QObject * {
+ return LauncherHelper::instance();
+ });
+ registered = true;
</code_context>
<issue_to_address>
**issue:** Consider qualifying LauncherHelper with its namespace in both the template parameter and the factory lambda.
Since `LauncherHelper` lives in the `dock` namespace, please qualify it as `dock::LauncherHelper` in both the `qmlRegisterSingletonType` template parameter and the lambda return to avoid potential name lookup/ODR issues if another `LauncherHelper` is introduced elsewhere.
```cpp
qmlRegisterSingletonType<dock::LauncherHelper>(
"org.deepin.ds.dock.helper", 1, 0, "LauncherHelper",
[](QQmlEngine *, QJSEngine *) -> QObject * {
return dock::LauncherHelper::instance();
});
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| qmlRegisterSingletonType<LauncherHelper>("org.deepin.ds.dock.helper", 1, 0, "LauncherHelper", | ||
| [](QQmlEngine *, QJSEngine *) -> QObject * { | ||
| return LauncherHelper::instance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Consider qualifying LauncherHelper with its namespace in both the template parameter and the factory lambda.
Since LauncherHelper lives in the dock namespace, please qualify it as dock::LauncherHelper in both the qmlRegisterSingletonType template parameter and the lambda return to avoid potential name lookup/ODR issues if another LauncherHelper is introduced elsewhere.
qmlRegisterSingletonType<dock::LauncherHelper>(
"org.deepin.ds.dock.helper", 1, 0, "LauncherHelper",
[](QQmlEngine *, QJSEngine *) -> QObject * {
return dock::LauncherHelper::instance();
});
在 dock 空白区域右键打开菜单时,启动器应该随其他弹窗一起关闭。
此修改通过 LauncherHelper 单例类实现启动器的关闭功能。
修改内容:
PMS: BUG-323289
Summary by Sourcery
Ensure the dock closes the launcher when opening its context menu and expose a singleton helper for launcher control to QML.
Bug Fixes:
Enhancements:
Build: