Skip to content

Conversation

@mhduiy
Copy link
Contributor

@mhduiy mhduiy commented May 22, 2025

  1. Extracted windowRadius to a property for better maintainability
  2. Added borderColor property for DWindow based on theme type
  3. Implemented StyledBehindWindowBlur for improved background blur effect with theme-aware colors
  4. Added InsideBoxBorder component for consistent inner border styling
  5. Removed FloatingPanel background and delegated styling to new components
  6. Improved color handling with proper theme-based selections

These changes enhance the visual consistency and theme responsiveness of the OSD window while making the code more maintainable by separating styling concerns into dedicated components. The new implementation provides better visual feedback and matches the system theme more accurately.

style: 优化 OSD 窗口视觉效果

  1. 将 windowRadius 提取为属性提高可维护性
  2. 根据主题类型为 DWindow 添加 borderColor 属性
  3. 实现 StyledBehindWindowBlur 提供改进的背景模糊效果,支持主题颜色
  4. 添加 InsideBoxBorder 组件实现统一的内边框样式
  5. 移除 FloatingPanel 背景,将样式委托给新组件
  6. 改进颜色处理,支持基于主题的选择

这些变更增强了 OSD 窗口的视觉一致性和主题响应能力,同时通过将样式关注点
分离到专用组件中提高了代码可维护性。新实现提供了更好的视觉反馈,并能更准
确地匹配系统主题。

pms: BUG-294195

Summary by Sourcery

Enhance OSD window visual styling by centralizing radius and border properties, improving blur effects, and delegating appearance to dedicated components for consistent theme responsiveness and maintainability.

Enhancements:

  • Extract windowRadius into a property and add theme-based borderColor on the OSD window
  • Introduce StyledBehindWindowBlur for adaptive background blur with theme-aware colors
  • Add InsideBoxBorder component and remove FloatingPanel background styling to unify border rendering
  • Centralize color handling using theme-based selectors for consistent light/dark visual effects

@sourcery-ai
Copy link

sourcery-ai bot commented May 22, 2025

Reviewer's Guide

Refactors OSD window styling by extracting windowRadius to a dedicated property, adding theme-aware DWindow borderColor, introducing StyledBehindWindowBlur and InsideBoxBorder components for consistent blur and inner borders, removing legacy FloatingPanel styling, and centralizing theme-based color selection for improved maintainability and visual consistency.

Class Diagram: OSD Window Styling Refactor

classDiagram
    class Window_OSD {
        +windowRadius: var <<new_property>>
        +D_DWindow_windowRadius: var /* updated to use root.windowRadius */
        +D_DWindow_borderColor: color <<new_property>>
        +color: "transparent"
        +osdView: Item
        +isSingleView: bool
    }
    note for Window_OSD "Main OSD Window (main.qml from panels/notification/osd/package/main.qml).\nKey changes:\n- 'windowRadius' property extracted and defined on root.\n- 'D.DWindow.borderColor' added, theme-dependent.\n- 'D.DWindow.windowRadius' updated to use root.windowRadius." 

    class StyledBehindWindowBlur {
        <<New Component>>
        +control: Item
        +anchors: fill
        +blendColor: color /* theme-aware, logic detailed in separate flow diagram */
    }
    note for StyledBehindWindowBlur "org.deepin.dtk.StyledBehindWindowBlur (D.StyledBehindWindowBlur)\nNew component added to Window_OSD for improved background blur effect." 

    class InsideBoxBorder {
        <<New Component>>
        +insideBorderColor: D_Palette
        +radius: var /* uses Window_OSD.windowRadius */
        +anchors: fill
        +z: int
        +color: ColorSelector_insideBorderColor
    }
    note for InsideBoxBorder "org.deepin.dtk.InsideBoxBorder (D.InsideBoxBorder)\nNew component added to Window_OSD for consistent inner border styling." 

    class ControlItem_Delegate {
        +contentItem: model.data
        -- background: D_FloatingPanel /* styling removed */ --
    }
    note for ControlItem_Delegate "Represents the sourceComponent for items in the OSD Repeater.\nBackground styling previously done by D.FloatingPanel is removed.\nVisuals now enhanced by Window_OSD's global effects (StyledBehindWindowBlur, InsideBoxBorder)." 

    class D_FloatingPanel {
        -- backgroundColor --
        -- insideBorderColor --
        -- outsideBorderColor --
    }
    note for D_FloatingPanel "org.deepin.dtk.D.FloatingPanel\nIts role for background and border styling of OSD items (ControlItem_Delegate) has been removed in this context." 

    Window_OSD "1" o-- "1" StyledBehindWindowBlur : uses
    Window_OSD "1" o-- "1" InsideBoxBorder : uses
    Window_OSD "1" *-- "0..N" ControlItem_Delegate : creates_delegates_for
Loading

File-Level Changes

Change Details Files
Extract windowRadius to a reusable property
  • Define property var windowRadius based on isSingleView or platformTheme
  • Bind D.DWindow.windowRadius to the new root.windowRadius property
panels/notification/osd/package/main.qml
Make DWindow borderColor theme-aware
  • Add D.DWindow.borderColor with conditional dark/light RGBA values
panels/notification/osd/package/main.qml
Implement StyledBehindWindowBlur for background blur
  • Add D.StyledBehindWindowBlur component filling the window
  • Compute blendColor via DS.Style.control.selectColor or fallback no-blur colors
panels/notification/osd/package/main.qml
Introduce InsideBoxBorder for inner border styling
  • Add D.InsideBoxBorder with customizable insideBorderColor palette
  • Bind radius to windowRadius, fill anchors, set z-order and color via D.ColorSelector
panels/notification/osd/package/main.qml
Remove legacy FloatingPanel background styling
  • Delete D.FloatingPanel block and its backgroundColor, border and shadow properties
panels/notification/osd/package/main.qml
Centralize theme-based color handling
  • Use DS.Style.control and D.ColorSelector for dynamic color selection
  • Replace hard-coded palettes with theme-aware selectors in blur and borders
panels/notification/osd/package/main.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

@mhduiy mhduiy requested a review from 18202781743 May 22, 2025 03:34
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 @mhduiy - I've reviewed your changes - here's some feedback:

  • Consider using a typed property real windowRadius instead of var to make the numeric intent explicit.
  • Extract the hard-coded RGBA values in StyledBehindWindowBlur.blendColor into theme/style tokens or palette entries to avoid magic numbers and improve consistency.
  • Verify that enabling both D.DWindow.enableBlurWindow and StyledBehindWindowBlur doesn’t cause redundant blur layers or impact rendering performance.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@mhduiy mhduiy requested a review from yixinshark May 22, 2025 05:41
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

1. Extracted windowRadius to a property for better maintainability
2. Added borderColor property for DWindow based on theme type
3. Implemented StyledBehindWindowBlur for improved background blur
effect with theme-aware colors
4. Added InsideBoxBorder component for consistent inner border styling
5. Removed FloatingPanel background and delegated styling to new
components
6. Improved color handling with proper theme-based selections

These changes enhance the visual consistency and theme responsiveness
of the OSD window while making the code more maintainable by separating
styling concerns into dedicated components. The new implementation
provides better visual feedback and matches the system theme more
accurately.

style: 优化 OSD 窗口视觉效果

1. 将 windowRadius 提取为属性提高可维护性
2. 根据主题类型为 DWindow 添加 borderColor 属性
3. 实现 StyledBehindWindowBlur 提供改进的背景模糊效果,支持主题颜色
4. 添加 InsideBoxBorder 组件实现统一的内边框样式
5. 移除 FloatingPanel 背景,将样式委托给新组件
6. 改进颜色处理,支持基于主题的选择

这些变更增强了 OSD 窗口的视觉一致性和主题响应能力,同时通过将样式关注点
分离到专用组件中提高了代码可维护性。新实现提供了更好的视觉反馈,并能更准
确地匹配系统主题。

pms: BUG-294195
@mhduiy
Copy link
Contributor Author

mhduiy commented May 26, 2025

/forcemerge

@deepin-ci-robot
Copy link

deepin pr auto review

关键摘要:

  • D.DWindow.windowRadius属性中,使用root.windowRadius来动态设置窗口半径,这是一个好的做法,提高了代码的可维护性。
  • 新增的D.StyledBehindWindowBlurD.InsideBoxBorder组件增加了窗口的视觉效果,但需要确保这些组件的引入不会对性能产生负面影响。
  • blendColor计算中,使用了DS.Style.control.selectColor方法,需要确认该方法是否已经过优化,以避免性能问题。
  • 新增的D.InsideBoxBorder组件的insideBorderColor属性使用了D.Palette对象,这可能会导致重复计算,建议优化。

是否建议立即修改:

  • 是,特别是对于可能影响性能的代码部分,应该立即进行优化。

@deepin-bot
Copy link

deepin-bot bot commented May 26, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit f9e204b into linuxdeepin:master May 26, 2025
7 of 10 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