Skip to content

fix: use application theme window radius and listen for changes - #269

Merged
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:fix/window-radius-from-theme
Jun 12, 2026
Merged

fix: use application theme window radius and listen for changes#269
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:fix/window-radius-from-theme

Conversation

@18202781743

@18202781743 18202781743 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

变更说明

使用应用主题设置窗口圆角并监听变化

修改内容

  1. DGuiApplicationHelper::applicationTheme() 获取 windowRadius
  2. 通过 DPlatformWindowHandle::setWindowRadius() 设置窗口圆角
  3. 监听 DPlatformTheme::windowRadiusChanged 信号实时更新

测试验证

  1. 验证窗口圆角与当前应用主题设置一致
  2. 测试应用主题更新时圆角变化
  3. 验证圆角实时应用到窗口
  4. 检查圆角变化过程中无视觉异常

关联 Issues


🤖 Generated with Claude Code

Summary by Sourcery

Align window corner radius with the current application theme and keep it in sync with theme changes.

Enhancements:

  • Initialize the main window's corner radius from the application theme instead of the window handle default.
  • Automatically update the window's corner radius when the application theme's window radius setting changes.

1. Replace window handle's local window radius with application theme's
window radius for consistency
2. Add listener for windowRadiusChanged signal to update corner radius
dynamically
3. Ensure the window radius updates when application theme properties
change

Influence:
1. Verify window corner radius matches the application theme setting
2. Test that changing application theme updates corner radius in real-
time
3. Check that corner radius remains consistent across different system
themes
4. Validate no visual glitches when radius changes during runtime

PMS: BUG-289145
@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Aligns the main window’s corner radius with the application theme and keeps it updated when the theme’s window radius changes.

Sequence diagram for window radius updates from application theme

sequenceDiagram
    participant DGuiApplicationHelper
    participant DPlatformTheme
    participant MainWindow
    participant DPlatformWindowHandle

    rect rgb(230,230,230)
        MainWindow->>DGuiApplicationHelper: instance()
        DGuiApplicationHelper-->>MainWindow: DGuiApplicationHelper*
        MainWindow->>DGuiApplicationHelper: applicationTheme()
        DGuiApplicationHelper-->>MainWindow: DPlatformTheme*
        MainWindow->>DPlatformTheme: windowRadius()
        DPlatformTheme-->>MainWindow: int
        MainWindow->>DPlatformWindowHandle: setWindowRadius(m_cornerRadius)
    end

    rect rgb(230,230,230)
        DPlatformTheme-->>MainWindow: windowRadiusChanged(newRadius)
        alt [m_cornerRadius != newRadius]
            MainWindow->>MainWindow: update m_cornerRadius
            MainWindow->>DPlatformWindowHandle: setWindowRadius(m_cornerRadius)
            MainWindow->>MainWindow: update()
        end
    end
Loading

File-Level Changes

Change Details Files
Initialize the main window’s corner radius from the application theme and apply it to the platform window handle.
  • Include DPlatformTheme to access theme-related window radius information.
  • In initUI, obtain the DPlatformTheme from DGuiApplicationHelper::applicationTheme().
  • Read the window radius from the theme instead of from the window handle and store it in m_cornerRadius.
  • Immediately apply the retrieved radius to the platform window via m_windowHandle->setWindowRadius().
dde-clipboard/mainwindow.cpp
Listen for application theme window radius changes and update the window accordingly at runtime.
  • In initConnect, obtain the current DPlatformTheme from DGuiApplicationHelper::applicationTheme().
  • Connect the DPlatformTheme::windowRadiusChanged signal to a lambda on MainWindow that receives the new radius.
  • Skip updates when the radius is unchanged to avoid redundant work.
  • On radius change, update m_cornerRadius, call m_windowHandle->setWindowRadius, and trigger repaint via update().
dde-clipboard/mainwindow.cpp

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

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:

  • You call DGuiApplicationHelper::instance()->applicationTheme() twice in initUI and initConnect; consider retrieving the theme once (or storing it as a member) and reusing it to avoid duplication and potential inconsistencies if the theme object changes.
  • Before using theme in both initUI and initConnect, consider guarding against a null applicationTheme() pointer to avoid crashes in case it is not available in some environments.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You call `DGuiApplicationHelper::instance()->applicationTheme()` twice in `initUI` and `initConnect`; consider retrieving the theme once (or storing it as a member) and reusing it to avoid duplication and potential inconsistencies if the theme object changes.
- Before using `theme` in both `initUI` and `initConnect`, consider guarding against a null `applicationTheme()` pointer to avoid crashes in case it is not available in some environments.

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.

@18202781743
18202781743 requested review from BLumia and mhduiy June 12, 2026 05:20
@18202781743
18202781743 merged commit 0d76bb0 into linuxdeepin:master Jun 12, 2026
15 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.

2 participants