From 0213a3833c83879ced7aedf1c629c906e955d449 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 26 Apr 2022 10:50:29 +0200 Subject: [PATCH] Fix the tooltip not re-sizing I'm not entirely sure if this fixes it on windows, but it does at least fix things on Linux. There are a few important changes to note here: 1. Increased the time of the fade timer to 200ms 2. Removed the mousearea, instead using the hover of scrollview So why are these important? Nr 1 seems to be because updates seem to be faster? If I set it to 100 I could get it to work reasonably well on qt5, but in qt6, it's about 50% of the times that i'm too slow. So we need the extra time. As for the mouse area, it seems that the scrollview was eating up all the hover / containsMouse events. As scrollview has the same properties that we need, we can just get rid of the mouseArea CURA-9112 --- resources/qml/PrintSetupTooltip.qml | 47 ++++++++++++----------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/resources/qml/PrintSetupTooltip.qml b/resources/qml/PrintSetupTooltip.qml index 5e5b1dce73..58fb86d764 100644 --- a/resources/qml/PrintSetupTooltip.qml +++ b/resources/qml/PrintSetupTooltip.qml @@ -11,7 +11,7 @@ UM.PointingRectangle id: base property real sourceWidth: 0 width: UM.Theme.getSize("tooltip").width - height: UM.Theme.getSize("tooltip").height + height: textScroll.height + UM.Theme.getSize("tooltip_margins").height * 2 color: UM.Theme.getColor("tooltip") arrowSize: UM.Theme.getSize("default_arrow").width @@ -20,7 +20,7 @@ UM.PointingRectangle Behavior on opacity { - NumberAnimation { duration: 100; } + NumberAnimation { duration: 200; } } property alias text: label.text @@ -59,16 +59,19 @@ UM.PointingRectangle base.opacity = 0; } - MouseArea + ScrollView { - enabled: parent.opacity > 0 - visible: enabled - anchors.fill: parent - acceptedButtons: Qt.NoButton - hoverEnabled: true + id: textScroll + width: parent.width + height: Math.min(label.height, base.parent.height) + + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ScrollBar.vertical.policy: ScrollBar.AsNeeded + + hoverEnabled: parent.opacity > 0 onHoveredChanged: { - if(containsMouse && base.opacity > 0) + if(hovered && base.opacity > 0) { base.show(Qt.point(target.x - 1, target.y - UM.Theme.getSize("tooltip_arrow_margins").height / 2)); //Same arrow position as before. } @@ -78,26 +81,16 @@ UM.PointingRectangle } } - ScrollView + UM.Label { - id: textScroll - width: base.width - height: base.height + id: label + x: UM.Theme.getSize("tooltip_margins").width + y: UM.Theme.getSize("tooltip_margins").height + width: textScroll.width - 2 * UM.Theme.getSize("tooltip_margins").width - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - ScrollBar.vertical.policy: ScrollBar.AsNeeded - - UM.Label - { - id: label - x: UM.Theme.getSize("tooltip_margins").width - y: UM.Theme.getSize("tooltip_margins").height - width: base.width - UM.Theme.getSize("tooltip_margins").width * 2 - - wrapMode: Text.Wrap - textFormat: Text.RichText - color: UM.Theme.getColor("tooltip_text") - } + wrapMode: Text.Wrap + textFormat: Text.RichText + color: UM.Theme.getColor("tooltip_text") } } }