Skip to content

Conversation

@Ivy233
Copy link
Contributor

@Ivy233 Ivy233 commented Jan 19, 2026

在 dock 空白区域右键打开菜单时,启动器应该随其他弹窗一起关闭。
此修改通过 LauncherHelper 单例类实现启动器的关闭功能。

修改内容:

  • 新增 LauncherHelper 类,通过 DBus 调用启动器的 Hide 方法
  • 在 dockpanel.cpp 中注册 LauncherHelper 为 QML 单例
  • 在 MenuHelper.qml 中打开菜单时调用 LauncherHelper.hideLauncher()
  • 简化 MenuHelper.qml 中 aboutToHide 连接的处理方式
  • 更新 CMakeLists.txt 添加新的源文件
  • dde-launchpad发现有接口,所以那边没有pr,但是这边没接口,所以有了这发提交。

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:

  • Close the application launcher when opening a context menu from the dock blank area so it behaves consistently with other pop-ups.

Enhancements:

  • Introduce a QML-accessible LauncherHelper singleton to control the launcher via D-Bus.
  • Simplify dock menu lifecycle handling in MenuHelper by streamlining about-to-hide connections.

Build:

  • Include the new launcher helper sources in the dock panel build configuration.

在 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>
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 19, 2026

Reviewer's Guide

Implements 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 menu

sequenceDiagram
    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()
Loading

Class diagram for new dock LauncherHelper singleton

classDiagram
    class dock_LauncherHelper {
        +static LauncherHelper* instance()
        +void hideLauncher()
        -LauncherHelper(QObject *parent)
        -~LauncherHelper()
    }
Loading

File-Level Changes

Change Details Files
Add LauncherHelper singleton class that hides the launcher via D-Bus and expose it to QML from dockpanel initialization.
  • Introduce dock::LauncherHelper QObject singleton with Q_INVOKABLE hideLauncher() that calls org.deepin.dde.Launcher1.Hide over QDBusInterface and logs errors/success via a dedicated logging category.
  • Provide a thread-safe-style static instance() accessor returning a single LauncherHelper instance.
  • Register LauncherHelper as a QML singleton type under org.deepin.ds.dock.helper 1.0 in DockPanel::init(), guarding with a static bool to avoid duplicate registrations.
panels/dock/launcherhelper.h
panels/dock/launcherhelper.cpp
panels/dock/dockpanel.cpp
Use LauncherHelper from QML when opening dock menus and simplify menu hide handling.
  • Import the org.deepin.ds.dock.helper 1.0 module in MenuHelper.qml and invoke LauncherHelper.hideLauncher() whenever a new dock menu is opened to ensure the launcher closes alongside other popups.
  • Keep only a lightweight aboutToHide connection that clears activeMenu, simplifying previous handling logic.
panels/dock/MenuHelper.qml
Update build configuration to compile the new helper.
  • Add launcherhelper.cpp and launcherhelper.h to the dock panel CMake file so the new helper is built and linked.
panels/dock/CMakeLists.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a 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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +64 to +66
qmlRegisterSingletonType<LauncherHelper>("org.deepin.ds.dock.helper", 1, 0, "LauncherHelper",
[](QQmlEngine *, QJSEngine *) -> QObject * {
return LauncherHelper::instance();
Copy link

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();
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant