Skip to content

fix: correct edit toolbar button hover/press colors - #426

Open
JWWTSL wants to merge 1 commit into
linuxdeepin:masterfrom
JWWTSL:agent/pms-bug-bot/32445a5f4c9c
Open

JWWTSL wants to merge 1 commit into
linuxdeepin:masterfrom
JWWTSL:agent/pms-bug-bot/32445a5f4c9c

Conversation

@JWWTSL

@JWWTSL JWWTSL commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

Edit mode buttons (ToolbarButton in EditToolbar.qml and ModeButton in EditPropertyPanel.qml) used bare DTK.ToolButton without any D.Palette color override, inheriting DTK's default CrystalColor palette where hover applies a dark overlay (button becomes darker) and press applies an even darker overlay. The design spec requires the opposite: hover should be lighter (white overlay) and press should be darker. Additionally, dark theme variants were missing entirely, causing incorrect color direction in dark mode. Key evidence: (1) both components had zero palette/color code in their definitions; (2) the main-view ToolbarIconButton.qml already uses the correct P.ButtonPanel + D.Palette override pattern, proving the omission.

Fix Approach

Add background: P.ButtonPanel with a custom DTK.Palette override covering color1/color2/insideBorderColor/outsideBorderColor for normal/hovered/pressed (and their dark variants), matching the already-proven pattern in ToolbarIconButton.qml. This is a pure addition (+144 lines, 0 deletions) — no existing code lines are modified.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Pure additive change (no existing lines modified), following the proven ToolbarIconButton.qml pattern; no external references (both are QML inline component used only within their own files).
  • Checked/selected state is unaffected — the highlighted/highlightedDark palette themes are intentionally not overridden, falling back to DTK default highlight color (identical to ToolbarIconButton.qml behavior).

Business Impact Scope

Affects only the image editor mode button appearance (edit toolbar buttons and property panel mode buttons). Users will see correct hover/press background colors matching the design spec in both light and dark themes. No functional logic, data flow, or interaction behavior changes.

Verification Suggestion

Test hover/press background colors on edit toolbar and property panel buttons in both light and dark themes; verify checked/selected state highlight color remains unchanged; verify normal (non-hover) appearance is unchanged.


根因分析

编辑模式按钮(EditToolbar.qml 的 ToolbarButton 和 EditPropertyPanel.qml 的 ModeButton)直接使用 DTK.ToolButton,未添加任何 D.Palette 颜色覆盖,继承了 DTK 默认的 CrystalColor 配色——hover 时叠加黑色(变暗),press 时更暗,与设计稿要求的"hover 更浅、press 更深"方向相反。深色主题下也缺少 dark 变体,导致配色方向错误。关键证据:(1)两个组件定义中无任何 palette/颜色覆盖代码;(2)主视图的 ToolbarIconButton.qml 已通过 P.ButtonPanel + D.Palette 覆盖实现了正确配色,证明编辑模式组件遗漏了相同处理。

修复方案

仿照 ToolbarIconButton.qml 的已验证模式,为两个按钮组件添加 background: P.ButtonPanel 及自定义 DTK.Palette 覆盖 color1/color2/insideBorderColor/outsideBorderColor(覆盖 normal/hovered/pressed 及对应 dark 变体)。纯新增改动(+144 行,0 删除),不修改任何已有代码行。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 纯新增改动(不修改已有代码行),参照 ToolbarIconButton.qml 已验证模式;两个组件均为 QML 内联 component,无外部引用。
  • 选中态(checked)不受影响——highlighted/highlightedDark 主题未覆盖,回退 DTK 默认高亮色,与 ToolbarIconButton.qml 行为一致。

业务影响范围

仅影响图片编辑模式按钮的外观(编辑工具栏按钮和属性面板模式按钮)。用户将在浅色和深色主题下看到与设计稿一致的 hover/press 背景色。不涉及任何功能逻辑、数据流或交互行为变化。

验证建议

在浅色和深色主题下测试编辑工具栏和属性面板按钮的 hover/press 背景色;验证选中态高亮色未受影响;验证 normal(非 hover)外观未变化。

Summary by Sourcery

Apply theme-aware palette styling to edit-mode buttons so their hover and pressed states match the intended visual design.

Bug Fixes:

  • Correct edit toolbar and property panel button hover and pressed colors in light and dark themes.

Enhancements:

  • Align edit-mode button styling with the established button panel palette behavior while preserving existing selected-state highlighting.

1. Root cause: EditToolbar.qml ToolbarButton and EditPropertyPanel.qml
   ModeButton used bare DTK.ToolButton without D.Palette override,
   inheriting DTK default CrystalColor where hover is darker than press
   (inverted) and dark theme lacks dark variants (wrong direction)
2. Fix: add background P.ButtonPanel with custom D.Palette covering
   color1/color2/insideBorderColor/outsideBorderColor, matching the
   pattern already proven in ToolbarIconButton.qml
3. Impact: hover/press background colors now match design spec for both
   light and dark themes; checked state unaffected (highlighted theme
   not overridden, falls back to DTK default)

Log: 修复图片编辑模式按钮 hover/press 背景色与设计稿不符的问题

Influence:
1. Test edit toolbar buttons hover/press colors in light theme
2. Test edit toolbar buttons hover/press colors in dark theme
3. Test property panel mode buttons hover/press colors in both themes
4. Verify checked/selected state highlight color unchanged
5. Verify normal (non-hover) appearance unchanged

fix: 修复图片编辑模式按钮 hover/press 背景色与设计稿不符

1. 根因:EditToolbar.qml 的 ToolbarButton 和 EditPropertyPanel.qml 的
   ModeButton 使用裸 DTK.ToolButton 未覆盖 D.Palette,直接继承 DTK 默认
   CrystalColor 配色,浅色主题下 hover 比 press 深(方向反了),深色主题
   缺少 dark 变体导致叠加黑色(方向错误)
2. 方案:添加 background P.ButtonPanel 并自定义 D.Palette 覆盖
   color1/color2/insideBorderColor/outsideBorderColor,参照
   ToolbarIconButton.qml 已验证的修复模式
3. 影响:hover/press 背景色在浅色和深色主题下均匹配设计稿;选中态
   不受影响(未覆盖 highlighted 主题,回退 DTK 默认高亮色)

Log: 修复图片编辑模式按钮 hover/press 背景色与设计稿不符的问题

Influence:
1. 测试浅色主题下编辑工具栏按钮 hover/press 背景色
2. 测试深色主题下编辑工具栏按钮 hover/press 背景色
3. 测试属性面板模式按钮 hover/press 背景色(浅色和深色主题)
4. 验证选中态高亮色未受影响
5. 验证 normal(非 hover)外观未变化

PMS: BUG-381139
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JWWTSL

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

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Both edit-mode button components now use the established ButtonPanel and DTK.Palette override pattern, correcting hover/press color direction in light and dark themes without changing interaction or selected-state behavior.

File-Level Changes

Change Details Files
Add explicit DTK button-panel palettes so edit-mode buttons use the intended hover, pressed, and theme-specific colors.
  • Import DTK style and private button-panel APIs.
  • Attach a ButtonPanel background sized from the shared icon-button style and bound to each button.
  • Define light/dark normal, hover, and pressed colors plus border colors; leave highlighted states to DTK defaults.
  • Apply the same palette implementation to both edit toolbar and property-panel mode buttons.
src/qml/EditToolbar.qml
src/qml/EditPropertyPanel.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

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 97 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复编辑工具栏按钮的 hover/press 颜色显示问题,通过为 EditPropertyPanel.qml 和 EditToolbar.qml 中的按钮添加 DTK ButtonPanel 背景组件及详细的 Palette 颜色配置 来实现正确的视觉效果。四维度分析中语法逻辑、代码性能、代码安全均无问题, 代码质量方面存在两文件间大量重复代码的可优化点,但不影响功能正确性。启发式扫描 与 OCR 审查均未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['建议将 ("transparent") 统一写为 "transparent",去掉多余括号,提升代码一致性 (EditPropertyPanel.qml 第54-55行、EditToolbar.qml 第144-145行)。']


2. 代码质量 ✅

评价: 存在重复代码 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['建议将 P.ButtonPanel 的颜色配置抽取为独立的 QML 组件或自定义属性组, 通过参数化的 button 属性引用实现复用,避免两处维护相同配置。 例如创建 EditButtonBackground.qml 组件,接受 button 属性参数。']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 建议抽取公共组件 EditButtonBackground.qml import QtQuick import org.deepin.dtk 1.0 as DTK import org.deepin.dtk.style 1.0 as DS import org.deepin.dtk.private 1.0 as P
P.ButtonPanel {
    property var button: null
    implicitWidth: DS.Style.iconButton.backgroundSize
    implicitHeight: DS.Style.iconButton.backgroundSize

    insideBorderColor: DTK.Palette {
        normal { common: Qt.rgba(1, 1, 1, 0.1); crystal: Qt.rgba(1, 1, 1, 0.1) }
        normalDark { common: Qt.rgba(1, 1, 1, 0.1); crystal: Qt.rgba(1, 1, 1, 0.1) }
        hovered { common: Qt.rgba(1, 1, 1, 0.2); crystal: Qt.rgba(1, 1, 1, 0.15) }
        pressed { common: Qt.rgba(1, 1, 1, 0.03); crystal: Qt.rgba(0, 0, 0, 0.03) }
    }
    outsideBorderColor: DTK.Palette {
        normal { common: Qt.rgba(0, 0, 0, 0.08); crystal: Qt.rgba(0, 0, 0, 0.08) }
        hovered { common: Qt.rgba(0, 0, 0, 0.2); crystal: Qt.rgba(0, 0, 0, 0.2) }
        pressed { common: "transparent"; crystal: "transparent" }
    }
    color1: DTK.Palette {
        normal { common: Qt.rgba(0, 0, 0, 0.1); crystal: Qt.rgba(1, 1, 1, 0.4) }
        normalDark { common: Qt.rgba(1, 1, 1, 0.1); crystal: Qt.rgba(1, 1, 1, 0.08) }
        hovered { common: Qt.rgba(0, 0, 0, 0.2); crystal: Qt.rgba(0, 0, 0, 0.1) }
        hoveredDark { common: Qt.rgba(1, 1, 1, 0.2); crystal: Qt.rgba(1, 1, 1, 0.2) }
        pressed { common: Qt.rgba(0, 0, 0, 0.15); crystal: Qt.rgba(0, 0, 0, 0.15) }
        pressedDark { common: Qt.rgba(1, 1, 1, 0.05); crystal: Qt.rgba(1, 1, 1, 0.05) }
    }
    color2: color1
}
// 在 EditPropertyPanel.qml / EditToolbar.qml 中使用: // background: EditButtonBackground { button: modeButton }

本报告由 AI 代码审查工具自动生成

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