-
Notifications
You must be signed in to change notification settings - Fork 55
fix: Close the launcher when opening the dock menu #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
fix: Close the launcher when opening the dock menu #1399
Conversation
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.
panels/dock/dockpanel.cpp
Outdated
| 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();
});43186e3 to
ddf209d
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, Ivy233 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
git提交,title使用英文,可以使用https://github.com/zccrs/git-commit-helper 进行提交, |
Call viewDeactivated() to close the fullscreen launchpad when right-clicking to open the dock menu. This ensures the launchpad is closed when the menu opens, meeting user expectations. PMS: BUG-323289
ddf209d to
07392a8
Compare
deepin pr auto review这段代码的变更是在处理鼠标右键点击事件时,在打开菜单前增加了一个 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进建议
总结这个改动主要是为了在打开右键菜单前重置视图状态,逻辑上是合理的。主要关注点应放在 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
|
/retest |
在 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: