Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ivy233 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 guide (collapsed on small PRs)Reviewer's GuideTyped colors now resolve through the current theme’s standard application palette when no QQuickControl ancestor is available, preserving control-specific behavior otherwise and preventing invalid color results in popup/window contexts. Flow diagram for typed color palette fallbackflowchart TD
A[Resolve target color] --> B{"targetColor.isTypedColor()"}
B -- No --> C["targetColor.color()"]
B -- Yes --> D{m_control available?}
D -- Yes --> E["targetColor.toColor(_d_getControlPalette(m_control))"]
D -- No --> F["targetColor.toColor(DGuiApplicationHelper::standardPalette(state->controlTheme))"]
C --> G[Return valid QColor]
E --> G
F --> G
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
TAG Bot New tag: 6.7.51 |
7d93864 to
1b23d50
Compare
| interactive: itemsView.count > maxVisibleItems | ||
| ScrollIndicator.vertical: ScrollIndicator { } | ||
| highlight: HighlightPanel { | ||
| highlight: Control { |
There was a problem hiding this comment.
直接把HighlightPanel的根从Item改成Control是不是也可以,
There was a problem hiding this comment.
这里先确认一下“根”指哪个对象:
如果指 HighlightPanel.qml 的根(当前是 Item),不建议直接改成 Control。ColorSelector::findAndSetControlParent() 是从元素自身开始找第一个 Control 的,根改成 Control 后会停在自身;MenuItem / ItemDelegate / NavigationTitle 这些把 HighlightPanel 当 background 的场景就不再继承宿主 Control 的 hovered / pressed / disabled 状态。FlowStyle 里 highlightPanel.background 定义了 hovered 变体,本地最小 QML 对比同一个 hovered 宿主下,Item 根是 Hovered / #4099d0,Control 根变成 Normal / #308cc6,会有可见的 hover 高亮色变化。
如果指 ArrowListView.qml 的根 FocusScope,也不建议改:Control 不继承 FocusScope,键盘焦点/导航语义会变;Menu.qml 的根是 T.Menu / Popup,更无法改成 Control。
所以当前只在 Menu / ArrowListView 的 ListView.highlight 外包一层 Control,作用域最小;C++ 的 standardPalette 回退继续覆盖独立/窗口级无 Control 场景。若希望减少改动,可以只保留 C++ 回退、去掉这两处包裹,但不建议改公共组件的根类型。
DQuickControlColorSelector::getColorOf() left the color invalid when a typed color (e.g. D.Color.Highlight used by HighlightPanel's backgroundColor) was resolved without any QQuickControl ancestor -- popup/window contexts such as Menu/ArrowListView highlights, or a window-level attached selector. The default-constructed invalid QColor has alpha 255, so HighlightPanel rendered as an opaque black block, and every read of the property printed "ColorSelector: The ... is an invalid color on ...". Fall back to DGuiApplicationHelper::standardPalette() of the current theme, consistent with the inactive-blend branch just below. Verified with a minimal QML scene (HighlightPanel under a plain Item): before, 5 warnings and backgroundColor invalid (#000000); after, no warning and a valid highlight color (#024cca). Also wrap the ListView.highlight HighlightPanel in a Control in the Qt6 Menu/ArrowListView components (qt6/src/qml/Menu.qml and qt6/src/qml/ArrowListView.qml). This gives dtk's own highlight the QQuickControl ancestor that ColorSelector expects, without changing the highlight geometry or z-order. The standard-palette fallback above still covers other control-less contexts (standalone HighlightPanel, window-level selectors). 修复:无 Control 祖先时类型化颜色回退到标准调色板 DQuickControlColorSelector::getColorOf() 在类型化颜色(如 HighlightPanel 的 backgroundColor 使用的 D.Color.Highlight)于无 QQuickControl 祖先的上下文(Menu/ArrowListView 高亮等 popup/window 场景,或窗口级附加 selector)解析时返回无效颜色。默认构造的无效 QColor alpha 为 255,导致 HighlightPanel 被画成不透明黑块,且每次 读取属性都打印 "ColorSelector: The ... is an invalid color on ..."。 回退到当前主题的 DGuiApplicationHelper::standardPalette(),与下方 inactive 混色分支保持一致。已用最小 QML 场景(HighlightPanel 挂在 纯 Item 下)验证:修复前 5 条告警且 backgroundColor 无效(#000000), 修复后无告警且返回有效高亮色(#024cca)。 同时将 Qt6 Menu/ArrowListView 的 ListView.highlight 用 Control 包裹 (qt6/src/qml/Menu.qml、qt6/src/qml/ArrowListView.qml),为 HighlightPanel 提供 ColorSelector 期望的 QQuickControl 祖先,不改变 高亮的几何与 z 序;上述标准调色板回退继续覆盖其他无 Control 场景 (独立 HighlightPanel、窗口级 selector)。 PMS: TASK-394335
1b23d50 to
0064daf
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ["可选:修正预存 TODO 注释中的拼写错误 'confict' -> 'conflict'(ArrowListView.qml 第11行、Menu.qml 第43行),虽非本次引入但可在后续清理。"] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 当前实现已正确,无需修改。以下为本次修复的核心逻辑参考: // dquickcontrolpalette.cpp - getColorOf() 中的回退逻辑 if (targetColor.isTypedColor()) {
if (m_control)
colorValue = targetColor.toColor(_d_getControlPalette(m_control));
else
// no control in the parent chain: fall back to standard palette
colorValue = targetColor.toColor(DGuiApplicationHelper::standardPalette(state->controlTheme));
} else {
colorValue = targetColor.color();
}本报告由 AI 代码审查工具自动生成 |
DQuickControlColorSelector::getColorOfColor() left the color invalid when a typed color (e.g. D.Color.Highlight used by HighlightPanel's backgroundColor) was resolved without any QQuickControl ancestor -- popup/window contexts such as Menu/ArrowListView highlights, or a window-level attached selector. The default-constructed invalid QColor has alpha 255, so HighlightPanel rendered as an opaque black block, and every read of the property printed
"ColorSelector: The ... is an invalid color on ...".
Fall back to DGuiApplicationHelper::standardPalette() of the current theme, consistent with the inactive-blend branch just below. Verified with a minimal QML scene (HighlightPanel under a plain Item): before, 5 warnings and backgroundColor invalid (#000000); after, no warning and a valid highlight color (#024cca).
修复:无 Control 祖先时类型化颜色回退到标准调色板
DQuickControlColorSelector::getColorOfColor() 在类型化颜色(如 HighlightPanel 的 backgroundColor 使用的 D.Color.Highlight)于无 QQuickControl 祖先的上下文(Menu/ArrowListView 高亮等 popup/window 场景,或窗口级附加 selector)解析时返回无效颜色。默认构造的无效
QColor alpha 为 255,导致 HighlightPanel 被画成不透明黑块,且每次
读取属性都打印 "ColorSelector: The ... is an invalid color on ..."。
回退到当前主题的 DGuiApplicationHelper::standardPalette(),与下方 inactive 混色分支保持一致。已用最小 QML 场景(HighlightPanel 挂在
纯 Item 下)验证:修复前 5 条告警且 backgroundColor 无效(#000000), 修复后无告警且返回有效高亮色(#024cca)。
PMS: TASK-394335
Summary by Sourcery
Prevent invalid typed-color resolution in popup and window-level highlight contexts by using the current theme’s standard palette as a fallback.
Bug Fixes: