Merge branch 'setting_tooltip_interaction' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2020-08-11 14:26:03 +02:00
commit 5840205442
No known key found for this signature in database
GPG Key ID: 3710727397403C91

View File

@ -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. // Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7 import QtQuick 2.7
@ -11,7 +11,7 @@ UM.PointingRectangle
id: base id: base
property real sourceWidth: 0 property real sourceWidth: 0
width: UM.Theme.getSize("tooltip").width 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") color: UM.Theme.getColor("tooltip")
arrowSize: UM.Theme.getSize("default_arrow").width arrowSize: UM.Theme.getSize("default_arrow").width
@ -59,18 +59,39 @@ UM.PointingRectangle
base.opacity = 0; base.opacity = 0;
} }
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onHoveredChanged:
{
if(containsMouse && 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.
}
else
{
base.hide();
}
}
ScrollView
{
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 Label
{ {
id: label; id: label
anchors x: UM.Theme.getSize("tooltip_margins").width
{ y: UM.Theme.getSize("tooltip_margins").height
top: parent.top; width: base.width - UM.Theme.getSize("tooltip_margins").width * 2
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; wrapMode: Text.Wrap;
textFormat: Text.RichText textFormat: Text.RichText
font: UM.Theme.getFont("default"); font: UM.Theme.getFont("default");
@ -78,3 +99,5 @@ UM.PointingRectangle
renderType: Text.NativeRendering renderType: Text.NativeRendering
} }
} }
}
}