Fix hover actions being taken away by scrolling

This commit is contained in:
Devin Lin
2021-03-17 21:12:59 -04:00
parent 525d691cf8
commit dd20df5c26
2 changed files with 34 additions and 21 deletions

View File

@@ -46,25 +46,30 @@ Item {
// show hover actions
onHoveredChanged: {
if (hovered && !Kirigami.Settings.isMobile) {
hoverComponent.parent = controlContainer;
hoverComponent.x = Qt.binding(() => controlContainer.width - hoverComponent.childWidth)
hoverComponent.y = -Kirigami.Units.largeSpacing * 4
hoverComponent.hovered = Qt.binding(() => controlContainer.hovered);
hoverComponent.showEdit = author.id === Controller.activeConnection.localUserId && (model.eventType === "emote" || model.eventType === "message");
hoverComponent.editClicked = () => {
if (hoverComponent.showEdit) {
edit(message, model.formattedBody, eventId);
}
};
hoverComponent.replyClicked = () => {
replyToMessage(author, message, eventId);
};
hoverComponent.reacted = emoji => {
currentRoom.toggleReaction(eventId, emoji);
};
updateHoverComponent();
}
}
// updates the global hover component to point to this delegate, and update its position
function updateHoverComponent() {
hoverComponent.x = column.mapToItem(page, hoverComponentX, hoverComponentY).x;
hoverComponent.y = column.mapToItem(page, hoverComponentX, hoverComponentY).y;
hoverComponent.hovered = Qt.binding(() => controlContainer.hovered);
hoverComponent.showEdit = author.id === Controller.activeConnection.localUserId && (model.eventType === "emote" || model.eventType === "message");
hoverComponent.updateFunction = updateHoverComponent;
hoverComponent.editClicked = () => {
if (hoverComponent.showEdit) {
edit(message, model.formattedBody, eventId);
}
};
hoverComponent.replyClicked = () => {
replyToMessage(author, message, eventId);
};
hoverComponent.reacted = emoji => {
currentRoom.toggleReaction(eventId, emoji);
};
}
DragHandler {
enabled: Kirigami.Settings.isMobile

View File

@@ -129,13 +129,23 @@ Kirigami.ScrollablePage {
}
// hover actions on a delegate, activated in TimelineContainer.qml
QQC2.Popup {
Connections {
target: page.flickable
function onContentYChanged() {
if (hoverActions.visible) {
hoverActions.updateFunction();
}
}
}
Item {
id: hoverActions
property bool showEdit
property bool hovered: false
visible: (hovered || hoverHandler.hovered) && !Kirigami.Settings.isMobile
property var updateFunction
property var editClicked
property var replyClicked
property var reacted
@@ -143,9 +153,7 @@ Kirigami.ScrollablePage {
property alias childWidth: hoverActionsRow.width
property alias childHeight: hoverActionsRow.height
background: Item {}
contentItem: RowLayout {
RowLayout {
id: hoverActionsRow
z: 4
spacing: 0