@@ -2,7 +2,7 @@ import QtQuick 2.7
22import QtQuick.Controls 2.3
33import QtQuick.Window 2.2
44
5- import UM 1.5 as UM
5+ import UM 1.3 as UM
66import Cura 1.1 as Cura
77
88Window
@@ -50,17 +50,28 @@ Window
5050 onXChanged: UM .Preferences .setValue (" sidebargui/settings_window_left" , x)
5151 onYChanged: UM .Preferences .setValue (" sidebargui/settings_window_top" , y)
5252
53- property string tooltipText
54- property var tooltipPosition
53+ property string toolTipText
54+ property int toolTipY
5555 function showTooltip ()
5656 {
57- toolTip .tooltipText = tooltipText
58- toolTip .show ()
57+ toolTip .text = toolTipText
58+ toolTip .target = Qt .point (4 * UM .Theme .getSize (" default_margin" ).width , toolTipY)
59+ if (toolTipY < (sidebarToolWindow .height / 2 ))
60+ {
61+ toolTip .y = toolTipY + 2 * UM .Theme .getSize (" default_margin" ).height
62+ toolTip .anchors .bottom = undefined
63+ }
64+ else
65+ {
66+ toolTip .y = toolTipY - toolTip .height - 1 * UM .Theme .getSize (" default_margin" ).height
67+ toolTip .anchors .top = undefined
68+ }
69+ toolTip .opacity = 1
5970 }
6071
6172 function hideTooltip ()
6273 {
63- toolTip .hide ()
74+ toolTip .opacity = 0
6475 }
6576
6677 visible: ! settingsDocked && settingsVisible && (prepareStageActive || ! preSlicedData)
7384 sidebarToolWindow .x = base .x + base .width - sidebarToolWindow .width + UM .Theme .getSize (" wide_margin" ).width
7485 sidebarToolWindow .y = base .y + UM .Theme .getSize (" wide_margin" ).width
7586 }
76- printSetupWindow .children = [sidebarContents]
87+ printSetupWindow .children = [sidebarContents, toolTip ]
7788 printSetupTooltip .visible = false // hide vestigial tooltip in main window
7889 }
7990 else
@@ -88,12 +99,47 @@ Window
8899 id: printSetupWindow
89100
90101 anchors .fill : parent
102+ }
103+
104+ Item
105+ {
106+ visible: false
91107
92- UM .ToolTip
108+ UM .PointingRectangle
93109 {
94110 id: toolTip
95111
96- width: printSetupWindow .width - 2 * UM .Theme .getSize (" default_margin" ).width
112+ width: printSetupWindow .width - 2 * UM .Theme .getSize (" default_margin" ).width - UM .Theme .getSize (" thick_margin" ).width
113+ x: UM .Theme .getSize (" thick_margin" ).width
114+ height: Math .min (label .height + 2 * UM .Theme .getSize (" default_margin" ).height , 400 )
115+
116+ property alias text: label .text
117+ color: UM .Theme .getColor (" tooltip" )
118+ arrowSize: UM .Theme .getSize (" default_arrow" ).width
119+
120+ opacity: 0
121+ // This should be disabled when invisible, otherwise it will catch mouse events.
122+ visible: opacity > 0
123+ enabled: visible
124+
125+ Behavior on opacity
126+ {
127+ NumberAnimation { duration: 200 ; }
128+ }
129+
130+ Label
131+ {
132+ id: label
133+ anchors .left : parent .left
134+ anchors .right : parent .right
135+ anchors .top : parent .top
136+ anchors .margins : UM .Theme .getSize (" tooltip_margins" ).width
137+ textFormat: Text .RichText
138+ color: UM .Theme .getColor (" tooltip_text" )
139+ font: UM .Theme .getFont (" default" )
140+ wrapMode: Text .Wrap
141+ renderType: Qt .platform .os == " osx" ? Text .QtRendering : Text .NativeRendering
142+ }
97143 }
98144 }
99145}
0 commit comments