diff --git a/panels/notification/bubble/package/BubbleDelegate.qml b/panels/notification/bubble/package/BubbleDelegate.qml index 6c4ba6484..a1dccd0ad 100644 --- a/panels/notification/bubble/package/BubbleDelegate.qml +++ b/panels/notification/bubble/package/BubbleDelegate.qml @@ -7,7 +7,8 @@ import QtQuick.Controls 2.15 Item { id: delegateRoot - width: 360 + width: ListView.view ? ListView.view.width : 360 + property var applet property var bubble: model property int maxCount: 3 // ListView 的 remove 动画执行的时候,remove Item的index会以负数的方式出现 @@ -15,10 +16,24 @@ Item { height: bubbleContent.height z: -realIndex + + HoverHandler { + id: delegateHoverHandler + margin: 8 + onHoveredChanged: { + if (delegateRoot.applet) { + delegateRoot.applet.setHoveredId(hovered && delegateRoot.bubble ? delegateRoot.bubble.id : 0) + } + } + } + Bubble { id: bubbleContent width: 360 + anchors.right: parent.right + anchors.rightMargin: 10 bubble: delegateRoot.bubble + parentHovered: delegateHoverHandler.hovered transformOrigin: Item.Top diff --git a/panels/notification/bubble/package/main.qml b/panels/notification/bubble/package/main.qml index 426576743..7af4f547a 100644 --- a/panels/notification/bubble/package/main.qml +++ b/panels/notification/bubble/package/main.qml @@ -91,21 +91,21 @@ Window { ListView { id: bubbleView - width: 360 + width: root.width height: contentHeight anchors { right: parent.right bottom: parent.bottom - rightMargin: 10 + rightMargin: 0 bottomMargin: 10 } function updateInputRegion() { root.DLayerShellWindow.setInputRegionRect( Math.ceil(bubbleView.x), - Math.ceil(bubbleView.y), - Math.ceil(bubbleView.width), - Math.ceil(Math.max(10, bubbleView.contentHeight)) + Math.ceil(bubbleView.y - 8), + Math.ceil(root.width), + Math.ceil(Math.max(10, bubbleView.contentHeight) + 8) ) } onContentHeightChanged: updateInputRegion() @@ -167,13 +167,17 @@ Window { } delegate: BubbleDelegate { + applet: Applet maxCount: model.bubbleCount } HoverHandler { + margin: 8 onPointChanged: { const local = point.position - let hoveredItem = bubbleView.itemAt(local.x, local.y) + const x = Math.min(Math.max(local.x, 0), bubbleView.width - 1) + const y = Math.min(Math.max(local.y, 0), bubbleView.height - 1) + let hoveredItem = bubbleView.itemAt(x, y) if (hoveredItem && hoveredItem.bubble) { Applet.setHoveredId(hoveredItem.bubble.id) } else {