From d710d42c0aed53df753eff7dfa90a4da005a8a7a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 5 Aug 2020 02:16:16 +0200 Subject: [PATCH 1/3] 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 } } From 3b8ae6439c61d9e63068ea91ef391c498608d2f6 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 5 Aug 2020 02:40:45 +0200 Subject: [PATCH 2/3] Put the setting tooltip in a scrollview You can now scroll through it if the description is too long for it to fit on the screen. --- resources/qml/PrintSetupTooltip.qml | 38 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/resources/qml/PrintSetupTooltip.qml b/resources/qml/PrintSetupTooltip.qml index cb9801f1bb..515427e655 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: label.height + UM.Theme.getSize("tooltip_margins").height * 2 + height: textScroll.height + UM.Theme.getSize("tooltip_margins").height * 2 color: UM.Theme.getColor("tooltip") arrowSize: UM.Theme.getSize("default_arrow").width @@ -75,23 +75,29 @@ UM.PointingRectangle } } - Label + ScrollView { - 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; + id: textScroll + width: parent.width + height: Math.min(label.height, base.parent.height) + + ScrollBar.horizontal: ScrollBar { + active: false //Only allow vertical scrolling. We should grow vertically only, but due to how the label is positioned it allocates space in the ScrollView horizontally. + } + + 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 + 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 } } } From 10857094070e79aabce25bd4fbcb394a0f5d3d68 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 5 Aug 2020 02:44:19 +0200 Subject: [PATCH 3/3] Fix arrow position if tooltip is too big to fit on the screen --- resources/qml/PrintSetupTooltip.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupTooltip.qml b/resources/qml/PrintSetupTooltip.qml index 515427e655..6b39842ec0 100644 --- a/resources/qml/PrintSetupTooltip.qml +++ b/resources/qml/PrintSetupTooltip.qml @@ -67,7 +67,7 @@ UM.PointingRectangle { if(containsMouse && base.opacity > 0) { - base.show(Qt.point(base.x + base.width, base.y + UM.Theme.getSize("tooltip_arrow_margins").height)); + base.show(Qt.point(target.x - 1, target.y - UM.Theme.getSize("tooltip_arrow_margins").height / 2)); //Same arrow position as before. } else {