From 1e72d0f91fa6d4972f1711b277c0164e5a1c0f33 Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Tue, 15 Jul 2025 19:13:03 +0800 Subject: [PATCH] refactor: simplify AlertToolTip implementation using FloatingPanel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- qt6/src/qml/AlertToolTip.qml | 41 ++++------------------------------- qt6/src/qml/FloatingPanel.qml | 2 +- qt6/src/qml/FlowStyle.qml | 19 ++++++++++++++-- 3 files changed, 22 insertions(+), 40 deletions(-) diff --git a/qt6/src/qml/AlertToolTip.qml b/qt6/src/qml/AlertToolTip.qml index 6608fb1b9..931a0592b 100644 --- a/qt6/src/qml/AlertToolTip.qml +++ b/qt6/src/qml/AlertToolTip.qml @@ -20,24 +20,10 @@ ToolTip { margins: 0 closePolicy: Popup.NoAutoClose - background: Item { - BoxShadow { - anchors.fill: _background - shadowBlur: 20 - shadowOffsetY: 6 - shadowColor: Qt.rgba(0, 0, 0, 0.2) - cornerRadius: _background.radius - } - - Rectangle { - property D.Palette backgroundColor: DS.Style.alertToolTip.background - property D.Palette borderColor: DS.Style.control.border - id: _background - anchors.fill: parent - color: D.ColorSelector.backgroundColor - border.color: D.ColorSelector.borderColor - radius: DS.Style.control.radius - } + background: FloatingPanel { + backgroundColor: DS.Style.alertToolTip.background + insideBorderColor: DS.Style.alertToolTip.insideBorder + outsideBorderColor: DS.Style.alertToolTip.outsideBorder } contentItem: Text { @@ -59,23 +45,4 @@ ToolTip { NumberAnimation { properties: "opacity"; from: 1.0; to: 0.0 } NumberAnimation { properties: "y"; from: control.target.height + DS.Style.control.spacing ; to: control.target.height } } - - BoxShadow { - property D.Palette dropShadowColor: DS.Style.alertToolTip.connecterdropShadow - property D.Palette backgroundColor: DS.Style.alertToolTip.connecterBackground - y: - height * (0.75) - control.topMargin - control.topPadding - width: DS.Style.alertToolTip.connectorWidth - height: DS.Style.alertToolTip.connectorHeight - shadowBlur: 4 - shadowOffsetY: 2 - shadowColor: D.ColorSelector.dropShadowColor - cornerRadius: _background.radius - - Rectangle { - anchors.fill: parent - color: parent.D.ColorSelector.backgroundColor - border.color: _background.D.ColorSelector.borderColor - border.width: 1 - } - } } diff --git a/qt6/src/qml/FloatingPanel.qml b/qt6/src/qml/FloatingPanel.qml index bed1c1d40..2b6f88292 100644 --- a/qt6/src/qml/FloatingPanel.qml +++ b/qt6/src/qml/FloatingPanel.qml @@ -81,7 +81,7 @@ Control { Loader { anchors.fill: backgroundRect - active: control.insideBorderColor && control.D.ColorSelector.controlTheme === D.ApplicationHelper.DarkType + active: control.insideBorderColor sourceComponent: InsideBoxBorder { radius: backgroundRect.radius color: control.D.ColorSelector.insideBorderColor diff --git a/qt6/src/qml/FlowStyle.qml b/qt6/src/qml/FlowStyle.qml index de7adacee..19751853e 100644 --- a/qt6/src/qml/FlowStyle.qml +++ b/qt6/src/qml/FlowStyle.qml @@ -619,8 +619,8 @@ QtObject { } property D.Palette background: D.Palette { - normal: Qt.rgba(247 / 255, 247 / 255, 247 / 255, 0.6) - normalDark: Qt.rgba(59 / 255, 59 / 255, 59 / 255, 0.6) + normal: Qt.rgba(247 / 255.0, 247 / 255.0, 247 / 255.0, 0.5) + normalDark: Qt.rgba(59 / 255.0, 59 / 255.0, 59 / 255.0, 0.5) } property D.Palette connecterdropShadow: D.Palette { @@ -631,6 +631,21 @@ QtObject { normal: Qt.rgba(1, 1, 1, 1) normalDark: Qt.rgba(0, 0, 0, 0.1) } + + property D.Palette dropShadow: D.Palette { + normal: Qt.rgba(0, 0, 0, 0.1) + normalDark: Qt.rgba(0, 0, 0, 0.2) + } + + property D.Palette outsideBorder: D.Palette { + normal: Qt.rgba(0, 0, 0, 0.1) + normalDark: Qt.rgba(0, 0, 0, 0.7) + } + + property D.Palette insideBorder: D.Palette { + normal: Qt.rgba(1, 1, 1, 0.3) + normalDark: Qt.rgba(1, 1, 1, 0.1) + } } property QtObject menu: QtObject {