Refactor hover actions

Refactor hover actions into their own component.
This commit is contained in:
James Graham
2023-05-21 15:36:43 +00:00
parent ccc952b65e
commit 8741fd8fed
4 changed files with 164 additions and 110 deletions

View File

@@ -12,6 +12,19 @@ import org.kde.neochat 1.0
ColumnLayout {
id: root
property string eventId: model.eventId
property var author: model.author
property int delegateType: model.delegateType
property bool verified: model.verified
readonly property real bubbleX: bubble.x + bubble.anchors.leftMargin
readonly property alias bubbleY: mainContainer.y
readonly property alias bubbleWidth: bubble.width
readonly property alias hovered: bubble.hovered
signal openContextMenu
signal openExternally()
signal replyClicked(string eventID)
@@ -99,21 +112,7 @@ ColumnLayout {
// show hover actions
onHoveredChanged: {
if (hovered && !Kirigami.Settings.isMobile) {
updateHoverComponent();
}
}
// Show hover actions by updating the global hover component to this delegate
function updateHoverComponent() {
if (!hoverComponent) {
return;
}
if (hovered && !Kirigami.Settings.isMobile) {
hoverComponent.delegate = root
hoverComponent.bubble = bubble
hoverComponent.event = model
hoverComponent.updateFunction = updateHoverComponent;
root.setHoverActionsToDelegate()
}
}
@@ -280,7 +279,6 @@ ColumnLayout {
}
}
background: Item {
Kirigami.ShadowedRectangle {
id: bubbleBackground
@@ -382,4 +380,8 @@ ColumnLayout {
});
contextMenu.open();
}
function setHoverActionsToDelegate() {
ListView.view.setHoverActionsToDelegate(root)
}
}