Skip to content

refactor: simplify AlertToolTip implementation using FloatingPanel#504

Merged
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master
Jul 15, 2025
Merged

refactor: simplify AlertToolTip implementation using FloatingPanel#504
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Copy Markdown
Contributor

@18202781743 18202781743 commented Jul 15, 2025

  1. Replaced custom background implementation in AlertToolTip with
    FloatingPanel component
  2. Removed redundant BoxShadow and connector elements as FloatingPanel
    handles these
  3. Updated FlowStyle with new palette properties for borders and shadows
  4. Modified FloatingPanel to always show inside border when color is
    specified
  5. Adjusted alertToolTip background opacity values for better visibility

The changes simplify the codebase by reusing existing FloatingPanel
component instead of maintaining duplicate shadow and border logic. This
makes the styling more consistent and easier to maintain. The opacity
adjustments improve visual appearance across different themes.

refactor: 使用 FloatingPanel 简化 AlertToolTip 实现

  1. 使用 FloatingPanel 组件替换 AlertToolTip 中的自定义背景实现
  2. 移除了冗余的 BoxShadow 和连接器元素,由 FloatingPanel 统一处理
  3. 更新 FlowStyle 添加新的边框和阴影调色板属性
  4. 修改 FloatingPanel 在指定颜色时始终显示内部边框
  5. 调整 alertToolTip 背景透明度值以获得更好的可视性

这些变更通过重用现有的 FloatingPanel 组件简化了代码库,而不是维护重复的
阴影和边框逻辑。这使得样式更加一致且易于维护。透明度调整改善了不同主题下
的视觉效果。

pms: BUG-293293

Summary by Sourcery

Simplify AlertToolTip styling by reusing the FloatingPanel component for backgrounds and borders, consolidate shadow and connector logic, introduce new palette properties in FlowStyle, enforce inside border rendering in FloatingPanel, and fine-tune background opacities for improved visibility.

Enhancements:

  • Replace AlertToolTip custom background and connector elements with the FloatingPanel component
  • Remove redundant BoxShadow and connector QML elements now handled by FloatingPanel
  • Update FlowStyle with new palette properties for dropShadow, insideBorder, and outsideBorder
  • Modify FloatingPanel to always render an inside border when a color is specified
  • Adjust AlertToolTip background opacity values for better visual contrast

1. Replaced custom background implementation in AlertToolTip with
FloatingPanel component
2. Removed redundant BoxShadow and connector elements as FloatingPanel
handles these
3. Updated FlowStyle with new palette properties for borders and shadows
4. Modified FloatingPanel to always show inside border when color is
specified
5. Adjusted alertToolTip background opacity values for better visibility

The changes simplify the codebase by reusing existing FloatingPanel
component instead of maintaining duplicate shadow and border logic. This
makes the styling more consistent and easier to maintain. The opacity
adjustments improve visual appearance across different themes.

refactor: 使用 FloatingPanel 简化 AlertToolTip 实现

1. 使用 FloatingPanel 组件替换 AlertToolTip 中的自定义背景实现
2. 移除了冗余的 BoxShadow 和连接器元素,由 FloatingPanel 统一处理
3. 更新 FlowStyle 添加新的边框和阴影调色板属性
4. 修改 FloatingPanel 在指定颜色时始终显示内部边框
5. 调整 alertToolTip 背景透明度值以获得更好的可视性

这些变更通过重用现有的 FloatingPanel 组件简化了代码库,而不是维护重复的
阴影和边框逻辑。这使得样式更加一致且易于维护。透明度调整改善了不同主题下
的视觉效果。

pms: BUG-293293
@18202781743 18202781743 requested review from BLumia and mhduiy July 15, 2025 11:14
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Jul 15, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#504
@deepin-ci-robot
Copy link
Copy Markdown
Contributor

deepin pr auto review

代码审查意见:

  1. 重构代码:在AlertToolTip.qml文件中,将原有的背景和阴影部分重构为FloatingPanel组件,简化了代码结构。但是,原有的阴影部分被完全移除,可能会影响视觉效果。建议确认是否所有阴影效果都已正确迁移到FloatingPanel组件中。

  2. 性能优化:在FloatingPanel.qml文件中,Loader组件的active属性依赖于control.insideBorderColorcontrol.D.ColorSelector.controlTheme。如果controlTheme的计算复杂度较高,可能会导致性能问题。建议评估是否有必要在每次属性变化时都重新计算controlTheme

  3. 代码可读性:在FlowStyle.qml文件中,新增的dropShadowoutsideBorderinsideBorder属性使得D.Palette更加复杂。建议为这些新属性添加注释,说明其用途和默认值,以提高代码的可读性。

  4. 颜色值精度:在FlowStyle.qml文件中,将颜色值的除法结果从整数改为浮点数,提高了颜色值的精度。这是一个好的做法,可以避免颜色值的小数部分被截断。

  5. 重复代码:在FlowStyle.qml文件中,normalnormalDark属性在dropShadowoutsideBorderinsideBorder属性中重复定义。建议将这些属性提取到一个公共的D.Palette对象中,以减少重复代码。

  6. 未使用的代码:在AlertToolTip.qml文件中,原有的阴影部分被完全移除,但相关的代码仍然保留。建议删除未使用的代码,以保持代码的整洁。

总体来说,代码重构和性能优化是主要改进点。建议在合并代码前,进行充分的测试,确保重构后的代码功能正常,并且没有引入新的问题。

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 15, 2025

Reviewer's Guide

This PR refactors AlertToolTip to reuse the FloatingPanel component for its background and shadow logic, updates FlowStyle with dedicated palette entries for borders and shadows (and adjusts alertToolTip opacity), and ensures FloatingPanel always displays its inside border when a color is provided.

Class diagram for AlertToolTip refactor using FloatingPanel

classDiagram
    class AlertToolTip {
        - background: FloatingPanel
        - contentItem: Text
    }
    class FloatingPanel {
        + backgroundColor
        + insideBorderColor
        + outsideBorderColor
    }
    AlertToolTip --> FloatingPanel : uses
Loading

Class diagram for updated FlowStyle palette properties

classDiagram
    class FlowStyle {
        + alertToolTip.background : D.Palette
        + alertToolTip.insideBorder : D.Palette
        + alertToolTip.outsideBorder : D.Palette
        + alertToolTip.dropShadow : D.Palette
    }
    class D.Palette {
        + normal
        + normalDark
    }
    FlowStyle --> D.Palette : uses
Loading

Class diagram for FloatingPanel inside border logic update

classDiagram
    class FloatingPanel {
        + insideBorderColor
        + showInsideBorder()
    }
    FloatingPanel : showInsideBorder() always active if insideBorderColor is set
Loading

File-Level Changes

Change Details Files
Simplified AlertToolTip styling by leveraging FloatingPanel.
  • Replaced custom background Item and BoxShadow with FloatingPanel component
  • Removed redundant BoxShadow and connector elements
qt6/src/qml/AlertToolTip.qml
Updated FlowStyle with new palette properties and adjusted opacities.
  • Tweaked alertToolTip background opacity values from 0.6 to 0.5
  • Added dropShadow, outsideBorder, and insideBorder palette entries
qt6/src/qml/FlowStyle.qml
Enhanced FloatingPanel to always show inside border when a color is specified.
  • Modified Loader.active condition to depend solely on insideBorderColor
qt6/src/qml/FloatingPanel.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

Copy link
Copy Markdown

@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 @18202781743 - I've reviewed your changes and they look great!


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
Copy Markdown
Contributor

[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

@18202781743 18202781743 merged commit 33b41e4 into linuxdeepin:master Jul 15, 2025
19 of 20 checks passed
18202781743 pushed a commit to linuxdeepin/dtk6declarative that referenced this pull request Jul 15, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#504
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