Skip to content

Commit 15da7e2

Browse files
committed
fix: keep notification close button hoverable at the edge
1. Extended the notification bubble input region to cover the close button area outside the card boundary 2. Added a stable close button hover state based on the outer hit area instead of relying on the loader item lifecycle 3. Kept the notification content layout unchanged while preserving the original visual position of the bubble Influence: 1. Test notification bubble close button hover at the top-right edge 2. Verify normal notification display position and stacking animation 3. Check that the time text and close button visibility switch correctly 4. Verify no QML binding loop or diagnostic log remains fix: 保持通知关闭按钮边缘区域可悬停 1. 扩展通知气泡输入区域,覆盖卡片边界外的关闭按钮区域 2. 基于外层热区增加稳定的关闭按钮悬停状态,避免依赖Loader对象生命周期 3. 保持通知内容布局不变,同时维持气泡原有视觉位置 Influence: 1. 测试通知气泡关闭按钮右上角边缘悬停 2. 验证通知显示位置和堆叠动画正常 3. 检查时间文本与关闭按钮显隐切换正确 4. 验证无QML绑定环和诊断日志残留 PMS: BUG-365963
1 parent 869b21f commit 15da7e2

3 files changed

Lines changed: 36 additions & 19 deletions

File tree

panels/notification/bubble/package/BubbleDelegate.qml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,35 @@ import QtQuick.Controls 2.15
77

88
Item {
99
id: delegateRoot
10-
width: 360
10+
readonly property int closeButtonInputMargin: 12
11+
width: ListView.view ? ListView.view.width : 382
1112
property var bubble: model
1213
property int maxCount: 3
1314
// ListView 的 remove 动画执行的时候,remove Item的index会以负数的方式出现
1415
property int realIndex: index < 0 ? ListView.view.count + index : index;
15-
16-
height: bubbleContent.height
16+
17+
height: bubbleContent.height + closeButtonInputMargin
1718
z: -realIndex
1819
Bubble {
1920
id: bubbleContent
2021
width: 360
22+
x: delegateRoot.closeButtonInputMargin
2123
bubble: delegateRoot.bubble
22-
24+
2325
transformOrigin: Item.Top
24-
26+
2527
y: {
28+
let base = delegateRoot.closeButtonInputMargin
2629
// normal bubble dont need to move
27-
if (realIndex < delegateRoot.maxCount)
28-
return 0
30+
if (realIndex < delegateRoot.maxCount)
31+
return base
2932

3033
let spacing = 10
3134
let peekAmount = 8
3235
// 根据 realIndex 计算出超出部分的折叠层数(最多折叠3层,再多层保留为了动画淡出)
3336
let levelsFolded = Math.min(realIndex - (delegateRoot.maxCount - 1), 3)
34-
let ret = levelsFolded * (delegateRoot.height + spacing - peekAmount)
35-
return ret
37+
let ret = levelsFolded * (bubbleContent.height + spacing - peekAmount)
38+
return base + ret
3639
}
3740

3841
scale: {

panels/notification/bubble/package/main.qml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,23 @@ Window {
9191

9292
ListView {
9393
id: bubbleView
94-
width: 360
94+
readonly property int bubbleContentWidth: 360
95+
readonly property int closeButtonInputMargin: 12
96+
readonly property int bubbleRightMargin: 10
97+
width: bubbleContentWidth + closeButtonInputMargin + bubbleRightMargin
9598
height: contentHeight
9699
anchors {
97100
right: parent.right
98101
bottom: parent.bottom
99-
rightMargin: 10
102+
rightMargin: 0
100103
bottomMargin: 10
101104
}
102105

103106
function updateInputRegion() {
104107
root.DLayerShellWindow.setInputRegionRect(
105108
Math.ceil(bubbleView.x),
106109
Math.ceil(bubbleView.y),
107-
Math.ceil(bubbleView.width),
110+
Math.ceil(bubbleView.width),
108111
Math.ceil(Math.max(10, bubbleView.contentHeight))
109112
)
110113
}

panels/notification/plugin/NotifyItemContent.qml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ NotifyItem {
1616
// Maximum retry attempts for focus operations when loader content is pending
1717
readonly property int maxFocusRetries: 5
1818
property bool parentHovered: false // External hover state from parent component
19-
property bool closeVisible: activeFocus || impl.hovered || parentHovered
19+
readonly property bool closeButtonHovered: closeHoverHandler.hovered
20+
property bool closeVisible: activeFocus || impl.hovered || parentHovered || closeButtonHovered
2021
property int miniContentHeight: NotifyStyle.contentItem.miniHeight
2122
property bool enableDismissed: true
2223
property alias clearButton: clearLoader.sourceComponent
@@ -104,16 +105,26 @@ NotifyItem {
104105
top: parent.top
105106
topMargin: -height / 2 + 2
106107
right: parent.right
107-
rightMargin: -width / 2 + 6
108+
rightMargin: -height / 2 + 6
109+
}
110+
width: 48
111+
height: 48
112+
hoverEnabled: false
113+
114+
HoverHandler {
115+
id: closeHoverHandler
108116
}
109-
width: 20
110-
height: 20
111117

112118
Loader {
113119
id: clearLoader
114120
anchors.right: parent.right
115-
// Show when mouse hovers or notification item has focus
116-
active: !(root.strongInteractive && root.actions.length > 0) && (root.closeVisible || closePlaceHolder.hovered)
121+
anchors.rightMargin: (closePlaceHolder.width - 20) / 2
122+
anchors.verticalCenter: parent.verticalCenter
123+
// Keep the close button alive while the pointer is inside the
124+
// enlarged hit area. Do not rely on Control.hovered here: the
125+
// button is partly outside the notification card and hover can
126+
// be lost on the top-right edge.
127+
active: !(root.strongInteractive && root.actions.length > 0) && root.closeVisible
117128
sourceComponent: SettingActionButton {
118129
id: closeBtn
119130
objectName: "closeNotify-" + root.appName
@@ -243,7 +254,7 @@ NotifyItem {
243254

244255
Loader {
245256
id: time
246-
active: !root.closeVisible && !closePlaceHolder.hovered
257+
active: !root.closeVisible
247258
visible: active
248259
Layout.alignment: Qt.AlignRight
249260
sourceComponent: Text {

0 commit comments

Comments
 (0)