From ecd53ff4100d719dac1aa3755dcbcc2c72a0421f Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Sun, 4 Oct 2026 21:16:41 +0800 Subject: [PATCH] fix: make HighlightPanel derive from Control MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HighlightPanel is used as ListView.highlight in Menu/ArrowListView without a Control ancestor. Its backgroundColor is a typed color (D.Color.Highlight), and DQuickControlColorSelector left it invalid when no Control was found, printing "ColorSelector: The ... is an invalid color" and rendering an opaque black highlight. Derive HighlightPanel from Control and use the background Rectangle as its contentItem, so ColorSelector finds a Control on the panel itself and resolves the typed color from its palette. This fixes all HighlightPanel uses without a caller-side wrapper or an application-wide color fallback. Because the panel is now its own control, it resolves palette/state from itself; enclosing Control hover/pressed/disabled state is not inherited. In-tree uses activate HighlightPanel for checked/highlighted state, so this keeps their normal appearance. 为 HighlightPanel 增加 Control 基类 HighlightPanel 在 Menu/ArrowListView 中作为 ListView.highlight 使用, 父链上没有 Control。其 backgroundColor 是类型化颜色 (D.Color.Highlight),找不到 Control 时 DQuickControlColorSelector 会返回无效颜色,打印 "ColorSelector: The ... is an invalid color", 并把高亮渲染成不透明黑色。 将 HighlightPanel 的根改为 Control,并把背景 Rectangle 作为其 contentItem,使 ColorSelector 能在面板自身找到 Control,并从自己的 palette 解析类型化颜色。这样无需调用方套壳,也无需增加应用级颜色兜底。 注意:面板现在以自身作为 Control,不再继承外层 Control 的 hovered/pressed/disabled 状态;库内使用点主要依赖 checked/highlighted 状态,因此正常外观保持不变。 PMS: TASK-394335 --- qt6/src/qml/HighlightPanel.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qt6/src/qml/HighlightPanel.qml b/qt6/src/qml/HighlightPanel.qml index b5f76e187..daffd3b7a 100644 --- a/qt6/src/qml/HighlightPanel.qml +++ b/qt6/src/qml/HighlightPanel.qml @@ -1,12 +1,13 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022-2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later import QtQuick +import QtQuick.Templates as T import org.deepin.dtk 1.0 as D import org.deepin.dtk.style 1.0 as DS -Item { +T.Control { id: panel property D.Palette backgroundColor: DS.Style.highlightPanel.background @@ -26,9 +27,8 @@ Item { // cornerRadius: backgroundRect.radius // } - Rectangle { + contentItem: Rectangle { id: backgroundRect - anchors.fill: parent color: panel.D.ColorSelector.backgroundColor radius: panel.radius }