From d710d42c0aed53df753eff7dfa90a4da005a8a7a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 5 Aug 2020 02:16:16 +0200 Subject: [PATCH] Keep tooltip visible when hovering over it Except when hovering over it while it's completely invisible. You just get this 100ms leeway time to transition from the setting to the tooltip. --- resources/qml/PrintSetupTooltip.qml | 47 ++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/resources/qml/PrintSetupTooltip.qml b/resources/qml/PrintSetupTooltip.qml index 41d68aef37..cb9801f1bb 100644 --- a/resources/qml/PrintSetupTooltip.qml +++ b/resources/qml/PrintSetupTooltip.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Ultimaker B.V. +// Copyright (c) 2020 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -59,22 +59,39 @@ UM.PointingRectangle base.opacity = 0; } - Label + MouseArea { - id: label; - anchors + anchors.fill: parent + hoverEnabled: true + onHoveredChanged: { - top: parent.top; - topMargin: UM.Theme.getSize("tooltip_margins").height; - left: parent.left; - leftMargin: UM.Theme.getSize("tooltip_margins").width; - right: parent.right; - rightMargin: UM.Theme.getSize("tooltip_margins").width; + if(containsMouse && base.opacity > 0) + { + base.show(Qt.point(base.x + base.width, base.y + UM.Theme.getSize("tooltip_arrow_margins").height)); + } + else + { + base.hide(); + } + } + + Label + { + id: label + anchors + { + top: parent.top; + topMargin: UM.Theme.getSize("tooltip_margins").height; + left: parent.left; + leftMargin: UM.Theme.getSize("tooltip_margins").width; + right: parent.right; + rightMargin: UM.Theme.getSize("tooltip_margins").width; + } + wrapMode: Text.Wrap; + textFormat: Text.RichText + font: UM.Theme.getFont("default"); + color: UM.Theme.getColor("tooltip_text"); + renderType: Text.NativeRendering } - wrapMode: Text.Wrap; - textFormat: Text.RichText - font: UM.Theme.getFont("default"); - color: UM.Theme.getColor("tooltip_text"); - renderType: Text.NativeRendering } }