Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion panels/notification/bubble/package/BubbleDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,33 @@ 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会以负数的方式出现
property int realIndex: index < 0 ? ListView.view.count + index : index;

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

Expand Down
16 changes: 10 additions & 6 deletions panels/notification/bubble/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
Loading