Repository navigation
Conversation
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
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideBoth 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
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['建议将 ("transparent") 统一写为 "transparent",去掉多余括号,提升代码一致性 (EditPropertyPanel.qml 第54-55行、EditToolbar.qml 第144-145行)。'] 2. 代码质量 ✅评价: 存在重复代码 ✅ 通过 潜在问题: 建议: ['建议将 P.ButtonPanel 的颜色配置抽取为独立的 QML 组件或自定义属性组, 通过参数化的 button 属性引用实现复用,避免两处维护相同配置。 例如创建 EditButtonBackground.qml 组件,接受 button 属性参数。'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在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 代码审查工具自动生成 |
Root Cause Analysis
Edit mode buttons (
ToolbarButtoninEditToolbar.qmlandModeButtoninEditPropertyPanel.qml) used bareDTK.ToolButtonwithout anyD.Palettecolor override, inheriting DTK's defaultCrystalColorpalette 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-viewToolbarIconButton.qmlalready uses the correctP.ButtonPanel+D.Paletteoverride pattern, proving the omission.Fix Approach
Add
background: P.ButtonPanelwith a customDTK.Paletteoverride coveringcolor1/color2/insideBorderColor/outsideBorderColorfornormal/hovered/pressed(and their dark variants), matching the already-proven pattern inToolbarIconButton.qml. This is a pure addition (+144 lines, 0 deletions) — no existing code lines are modified.Change Safety Assessment
Code Safety
ToolbarIconButton.qmlpattern; no external references (both are QML inlinecomponentused only within their own files).highlighted/highlightedDarkpalette themes are intentionally not overridden, falling back to DTK default highlight color (identical toToolbarIconButton.qmlbehavior).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,无外部引用。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:
Enhancements: