Skip to content

Commit 33b41e4

Browse files
committed
refactor: simplify AlertToolTip implementation using FloatingPanel
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
1 parent c7f8387 commit 33b41e4

3 files changed

Lines changed: 22 additions & 40 deletions

File tree

qt6/src/qml/AlertToolTip.qml

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,10 @@ ToolTip {
2020
margins: 0
2121
closePolicy: Popup.NoAutoClose
2222

23-
background: Item {
24-
BoxShadow {
25-
anchors.fill: _background
26-
shadowBlur: 20
27-
shadowOffsetY: 6
28-
shadowColor: Qt.rgba(0, 0, 0, 0.2)
29-
cornerRadius: _background.radius
30-
}
31-
32-
Rectangle {
33-
property D.Palette backgroundColor: DS.Style.alertToolTip.background
34-
property D.Palette borderColor: DS.Style.control.border
35-
id: _background
36-
anchors.fill: parent
37-
color: D.ColorSelector.backgroundColor
38-
border.color: D.ColorSelector.borderColor
39-
radius: DS.Style.control.radius
40-
}
23+
background: FloatingPanel {
24+
backgroundColor: DS.Style.alertToolTip.background
25+
insideBorderColor: DS.Style.alertToolTip.insideBorder
26+
outsideBorderColor: DS.Style.alertToolTip.outsideBorder
4127
}
4228

4329
contentItem: Text {
@@ -59,23 +45,4 @@ ToolTip {
5945
NumberAnimation { properties: "opacity"; from: 1.0; to: 0.0 }
6046
NumberAnimation { properties: "y"; from: control.target.height + DS.Style.control.spacing ; to: control.target.height }
6147
}
62-
63-
BoxShadow {
64-
property D.Palette dropShadowColor: DS.Style.alertToolTip.connecterdropShadow
65-
property D.Palette backgroundColor: DS.Style.alertToolTip.connecterBackground
66-
y: - height * (0.75) - control.topMargin - control.topPadding
67-
width: DS.Style.alertToolTip.connectorWidth
68-
height: DS.Style.alertToolTip.connectorHeight
69-
shadowBlur: 4
70-
shadowOffsetY: 2
71-
shadowColor: D.ColorSelector.dropShadowColor
72-
cornerRadius: _background.radius
73-
74-
Rectangle {
75-
anchors.fill: parent
76-
color: parent.D.ColorSelector.backgroundColor
77-
border.color: _background.D.ColorSelector.borderColor
78-
border.width: 1
79-
}
80-
}
8148
}

qt6/src/qml/FloatingPanel.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Control {
8181

8282
Loader {
8383
anchors.fill: backgroundRect
84-
active: control.insideBorderColor && control.D.ColorSelector.controlTheme === D.ApplicationHelper.DarkType
84+
active: control.insideBorderColor
8585
sourceComponent: InsideBoxBorder {
8686
radius: backgroundRect.radius
8787
color: control.D.ColorSelector.insideBorderColor

qt6/src/qml/FlowStyle.qml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ QtObject {
619619
}
620620

621621
property D.Palette background: D.Palette {
622-
normal: Qt.rgba(247 / 255, 247 / 255, 247 / 255, 0.6)
623-
normalDark: Qt.rgba(59 / 255, 59 / 255, 59 / 255, 0.6)
622+
normal: Qt.rgba(247 / 255.0, 247 / 255.0, 247 / 255.0, 0.5)
623+
normalDark: Qt.rgba(59 / 255.0, 59 / 255.0, 59 / 255.0, 0.5)
624624
}
625625

626626
property D.Palette connecterdropShadow: D.Palette {
@@ -631,6 +631,21 @@ QtObject {
631631
normal: Qt.rgba(1, 1, 1, 1)
632632
normalDark: Qt.rgba(0, 0, 0, 0.1)
633633
}
634+
635+
property D.Palette dropShadow: D.Palette {
636+
normal: Qt.rgba(0, 0, 0, 0.1)
637+
normalDark: Qt.rgba(0, 0, 0, 0.2)
638+
}
639+
640+
property D.Palette outsideBorder: D.Palette {
641+
normal: Qt.rgba(0, 0, 0, 0.1)
642+
normalDark: Qt.rgba(0, 0, 0, 0.7)
643+
}
644+
645+
property D.Palette insideBorder: D.Palette {
646+
normal: Qt.rgba(1, 1, 1, 0.3)
647+
normalDark: Qt.rgba(1, 1, 1, 0.1)
648+
}
634649
}
635650

636651
property QtObject menu: QtObject {

0 commit comments

Comments
 (0)