From 9c622b60b9cbf5a05fe3215cd3f6bdad872d3419 Mon Sep 17 00:00:00 2001
From: Nicolas Werner <nicolas.werner@hotmail.de>
Date: Mon, 7 Mar 2022 23:16:18 +0100
Subject: [PATCH] Fix flickering in hover menu

---
 resources/qml/MessageView.qml | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index 55860ad61..bbd198ab2 100644
--- a/resources/qml/MessageView.qml
+++ b/resources/qml/MessageView.qml
@@ -56,7 +56,7 @@ Item {
 
         anchors.rightMargin: scrollbar.interactive? scrollbar.width : 0
 
-        Rectangle {
+        Control {
             //closePolicy: Popup.NoAutoClose
 
             id: messageActions
@@ -64,27 +64,22 @@ Item {
             property Item attached: null
             property alias model: row.model
             // use comma to update on scroll
-            property var attachedPos: chat.contentY, chat.count, attached ? chat.mapFromItem(attached, attached ? attached.width - width : 0, -height) : null
-            readonly property int padding: Nheko.paddingSmall
+            property var attachedPos: chat.contentY, attached ? chat.mapFromItem(attached, attached ? attached.width - width : 0, -height) : null
+            padding: Nheko.paddingSmall
 
-            visible: Settings.buttonsInTimeline && !!attached && (attached.hovered || messageActionHover.hovered)
+            visible: Settings.buttonsInTimeline && !!attached && (attached.hovered || hovered)
             x: attached ? attachedPos.x : 0
             y: attached ? attachedPos.y : 0
             z: 10
-            height: row.implicitHeight + padding * 2
-            width: row.implicitWidth + padding * 2
+
+            background: Rectangle {
             color: Nheko.colors.window
             border.color: Nheko.colors.buttonText
             border.width: 1
             radius: padding
-
-            HoverHandler {
-                id: messageActionHover
-
-                grabPermissions: PointerHandler.CanTakeOverFromAnything
             }
 
-            Row {
+            contentItem: Row {
                 id: row
 
                 property var model
@@ -479,7 +474,7 @@ Item {
             TimelineRow {
                 id: timelinerow
 
-                hovered: messageActionHover.hovered ? (messageActions.model != undefined && messageActions.model.eventId == timelinerow.eventId) : wrapper.hovered
+                hovered: messageActions.hovered ? (messageActions.model != undefined && messageActions.model == timelinerow) : wrapper.hovered
 
                 proportionalHeight: wrapper.proportionalHeight
                 type: chat.model, wrapper.type
@@ -512,17 +507,19 @@ Item {
                 status: wrapper.status
                 relatedEventCacheBuster: wrapper.relatedEventCacheBuster
                 y: section.visible && section.active ? section.y + section.height : 0
-            }
 
-            onHoveredChanged: {
+                onHoveredChanged: {
+                    console.log("Hover changed: " + hovered + " w: " + wrapper.hovered + " h: "+ messageActions.hovered + " obj: " + timelinerow)
                 if (!Settings.mobileMode && hovered) {
-                    if (!messageActionHover.hovered) {
+                    if (!messageActions.hovered) {
                         messageActions.attached = timelinerow;
                         messageActions.model = timelinerow;
                     }
                 }
             }
 
+            }
+
             Connections {
                 function onMovementEnded() {
                     if (y + height + 2 * chat.spacing > chat.contentY + chat.height && y < chat.contentY + chat.height)
-- 
GitLab