Skip to content

feat: add windowTitle property for popup windows#1512

Merged
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master
Mar 19, 2026
Merged

feat: add windowTitle property for popup windows#1512
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Contributor

@18202781743 18202781743 commented Mar 19, 2026

Added windowTitle property to PanelMenu, PanelPopup, and
PanelToolTip QML components to distinguish different popup windows
for window managers like KWin. The title property was moved from
PanelPopupWindow.qml to individual component definitions to allow
customization per popup type. This enables better window management and
identification in compositors.

Log: Added window title support for panel popup windows to improve
window manager compatibility

Influence:

  1. Test that panel menus, popups, and tooltips display correctly with
    their respective window titles
  2. Verify window manager can properly identify and manage different
    popup types
  3. Check that popup positioning and functionality remain unchanged
  4. Test with different window managers to ensure compatibility
  5. Verify that the default window titles are correctly set for each
    popup type

feat: 为弹出窗口添加 windowTitle 属性

为 PanelMenu、PanelPopup 和 PanelToolTip QML 组件添加了 windowTitle
属性,以便窗口管理器(如 KWin)能够区分不同的弹出窗口。将标题属性从
PanelPopupWindow.qml 移动到各个组件定义中,允许按弹出类型进行自定义。这
使合成器能够更好地进行窗口管理和识别。

Log: 为面板弹出窗口添加窗口标题支持以改善窗口管理器兼容性

Influence:

  1. 测试面板菜单、弹出窗口和工具提示是否显示正确的窗口标题
  2. 验证窗口管理器能否正确识别和管理不同类型的弹出窗口
  3. 检查弹出窗口定位和功能是否保持不变
  4. 使用不同的窗口管理器测试以确保兼容性
  5. 验证每个弹出类型的默认窗口标题是否正确设置

Summary by Sourcery

Add configurable window titles for panel popup-related QML components to improve identification and handling by window managers.

New Features:

  • Introduce a windowTitle property to PanelMenu, PanelPopup, and PanelToolTip components with distinct default titles for each popup type.

Enhancements:

  • Set popup window titles from the owning components instead of hardcoding them in PanelPopupWindow to allow per-popup customization.
  • Update SPDX copyright years across the affected QML files.

Added windowTitle property to PanelMenu, PanelPopup, and
PanelToolTip QML components to distinguish different popup windows
for window managers like KWin. The title property was moved from
PanelPopupWindow.qml to individual component definitions to allow
customization per popup type. This enables better window management and
identification in compositors.

Log: Added window title support for panel popup windows to improve
window manager compatibility

Influence:
1. Test that panel menus, popups, and tooltips display correctly with
their respective window titles
2. Verify window manager can properly identify and manage different
popup types
3. Check that popup positioning and functionality remain unchanged
4. Test with different window managers to ensure compatibility
5. Verify that the default window titles are correctly set for each
popup type

feat: 为弹出窗口添加 windowTitle 属性

为 PanelMenu、PanelPopup 和 PanelToolTip QML 组件添加了 windowTitle
属性,以便窗口管理器(如 KWin)能够区分不同的弹出窗口。将标题属性从
PanelPopupWindow.qml 移动到各个组件定义中,允许按弹出类型进行自定义。这
使合成器能够更好地进行窗口管理和识别。

Log: 为面板弹出窗口添加窗口标题支持以改善窗口管理器兼容性

Influence:
1. 测试面板菜单、弹出窗口和工具提示是否显示正确的窗口标题
2. 验证窗口管理器能否正确识别和管理不同类型的弹出窗口
3. 检查弹出窗口定位和功能是否保持不变
4. 使用不同的窗口管理器测试以确保兼容性
5. 验证每个弹出类型的默认窗口标题是否正确设置
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 19, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a configurable windowTitle property to panel-related QML popup components so each popup type sets its own WM_NAME before showing, improving window manager identification, and removes the hard-coded title from the shared popup window wrapper.

Sequence diagram for setting windowTitle before showing panel popup windows

sequenceDiagram
    actor User
    participant PanelComponent
    participant PopupWindow
    participant WindowManager

    User->>PanelComponent: triggerPopup()
    PanelComponent->>PanelComponent: check readyBinding
    alt binding_ready
        PanelComponent->>PopupWindow: set currentItem
        PanelComponent->>PopupWindow: set title = windowTitle
        PanelComponent->>PopupWindow: show()
        opt requires_activation
            PanelComponent->>PopupWindow: requestActivate()
        end
        PopupWindow-->>WindowManager: expose WM_NAME_from_title
        WindowManager->>WindowManager: identify_and_manage_popup()
    else binding_not_ready
        PanelComponent-->>User: do_not_show_popup()
    end
Loading

Class diagram for panel popup QML components with windowTitle

classDiagram
    class PanelMenu {
        int menuX
        int menuY
        bool readyBinding
        string windowTitle
        showMenu()
    }

    class PanelPopup {
        int popupX
        int popupY
        bool readyBinding
        string windowTitle
        showPopup()
    }

    class PanelToolTip {
        int toolTipX
        int toolTipY
        bool readyBinding
        string windowTitle
        showToolTip()
    }

    class PanelPopupWindow {
        int width
        int height
        int flags
        font font
        show()
        requestActivate()
    }

    PanelMenu --> PanelPopupWindow : uses menuWindow
    PanelPopup --> PanelPopupWindow : uses popupWindow
    PanelToolTip --> PanelPopupWindow : uses toolTipWindow

    class WindowManager {
        identifyWindow()
        manageWindow()
    }

    PanelPopupWindow --> WindowManager : exposes WM_NAME_via_title
Loading

File-Level Changes

Change Details Files
Introduce a configurable windowTitle property for each panel popup type and apply it when showing the popup window.
  • Add a windowTitle string property with a type-specific default value to the panel menu, panel popup, and panel tooltip QML components
  • Set the underlying popup window's title from the new windowTitle property immediately before showing or activating the window
  • Remove the hardcoded title from the shared PanelPopupWindow wrapper so that titles are controlled by the owning components
frame/qml/PanelMenu.qml
frame/qml/PanelPopup.qml
frame/qml/PanelToolTip.qml
frame/qml/PanelPopupWindow.qml
Update copyright years in modified QML files.
  • Extend SPDX-FileCopyrightText year ranges to 2026 in the touched QML files
frame/qml/PanelMenu.qml
frame/qml/PanelPopup.qml
frame/qml/PanelToolTip.qml

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

@deepin-ci-robot
Copy link

deepin pr auto review

这段代码变更主要涉及QML文件中窗口标题属性的调整和版权年份的更新。以下是对代码的详细审查意见:

1. 语法逻辑审查

优点:

  • 代码语法正确,符合QML规范。
  • property string windowTitle 的声明和使用方式正确。
  • Qt.callLater 的使用合理,确保了在适当的时机设置窗口标题。

建议:

  • PanelMenu.qml 中,windowTitle 是在 Qt.callLater 中被设置的,而 PanelPopup.qmlPanelToolTip.qml 中是直接在函数中设置的。这种不一致性可能导致维护困难。建议统一处理方式。

2. 代码质量审查

优点:

  • 代码结构清晰,变量命名规范(如 windowTitle)。
  • 添加了有意义的注释 // WM_NAME, used for kwin.,说明了属性的用途。

建议:

  • 代码重复windowTitle 属性在三个文件中重复定义,可以考虑创建一个基类或混入(mixin)来复用这部分代码。
  • 魔法字符串"dde-shell/panelmenu" 等字符串硬编码在代码中,建议将其定义为常量或配置项,便于统一管理和修改。

3. 代码性能审查

分析:

  • 当前实现中,窗口标题是在每次显示窗口时设置的(menuWindow.title = windowTitle),这会产生轻微的性能开销,但影响极小。
  • 使用 Qt.callLater 是一个好的实践,可以避免不必要的重复计算。

建议:

  • 如果窗口标题在运行时不会改变,可以考虑在窗口创建时一次性设置,而不是每次显示时都设置。例如:
    Component.onCompleted: {
        menuWindow.title = windowTitle
    }

4. 代码安全审查

分析:

  • 代码中没有明显的安全漏洞。
  • 窗口标题的设置是可控的,没有直接使用外部输入。

建议:

  • 如果 windowTitle 属性未来可能从外部输入(如配置文件或用户输入),应该添加验证逻辑,防止注入攻击或显示不当内容。

5. 其他建议

  1. 版权年份更新

    • 将版权年份从 2024 更新为 2024 - 2026 是合理的,表明项目会持续维护到2026年。
  2. 代码一致性

    • 建议检查项目中其他类似的窗口组件,确保窗口标题的设置方式保持一致。
  3. 国际化考虑

    • 如果窗口标题需要支持多语言,建议使用 qsTr() 包装字符串,例如:
      property string windowTitle: qsTr("dde-shell/panelmenu")

改进后的代码示例

PanelMenu.qml 为例:

// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Item {
    // ... 其他属性 ...
    property string windowTitle: qsTr("dde-shell/panelmenu") // 支持国际化

    // ... 其他代码 ...

    Component.onCompleted: {
        menuWindow.title = windowTitle // 在窗口创建时设置标题
    }

    function open() {
        menuWindow.currentItem = control
        Qt.callLater(function () {
            menuWindow.show() // 显示窗口
            DS.grabMouse(menuWindow)
        })
    }
}

总结

这段代码变更整体质量良好,主要改进了窗口标题的管理方式。建议进一步统一处理方式、减少代码重复,并考虑国际化和性能优化。

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 left some high level feedback:

  • Instead of imperatively assigning *.title = windowTitle inside show()/open() paths, consider using a declarative binding like title: windowTitle on the window objects so that title updates propagate automatically if windowTitle changes while the popup is visible.
  • The windowTitle WM_NAME strings are currently hard-coded separately in three components; consider centralizing them (e.g., in a shared constants file or via a common base component) to avoid divergence and make future adjustments easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of imperatively assigning `*.title = windowTitle` inside `show()`/`open()` paths, consider using a declarative binding like `title: windowTitle` on the window objects so that title updates propagate automatically if `windowTitle` changes while the popup is visible.
- The `windowTitle` WM_NAME strings are currently hard-coded separately in three components; consider centralizing them (e.g., in a shared constants file or via a common base component) to avoid divergence and make future adjustments easier.

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.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@18202781743 18202781743 merged commit b87de4e into linuxdeepin:master Mar 19, 2026
11 of 12 checks passed
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.

3 participants