44import QtQuick 2.7
55import QtQuick.Controls 2.3
66import QtQuick.Window 2.2
7+ import QtQuick.Controls.Private 1.0
78
89import UM 1.3 as UM
910import Cura 1.1 as Cura
1213{
1314 id: stageMenu
1415
15- signal showTooltip (Item item, point location, string text)
16- signal hideTooltip ()
17-
1816 property var messageStack
1917 property var stagesListContainer
2018 property var applicationLogo
3028 property bool sidebarVisible: settingsVisible && (prepareStageActive || ! preSlicedData) && settingsDocked
3129 property real sidebarWidth: sidebarVisible ? printSetupSelector .width : 0
3230
31+ property var printSetupTooltip
32+
3333 Component .onCompleted :
3434 {
3535 is40 = (CuraSDKVersion == " 6.0.0" )
132132 headerBackground .height = mainWindowHeader .height + UM .Theme .getSize (" default_margin" ).height
133133 main .anchors .top = main .parent .top
134134 main .anchors .topMargin = UM .Theme .getSize (" default_margin" ).height
135+
136+ printSetupTooltip = tooltip // defined in Cura.qml
135137 }
136138
137139 Connections
@@ -181,6 +183,27 @@ Item
181183 }
182184 }
183185
186+ Connections
187+ {
188+ target: tooltip
189+ enabled: ! settingsDocked
190+ onTextChanged:
191+ {
192+ sidebarToolWindow .tooltipText = tooltip .text
193+ }
194+ onOpacityChanged:
195+ {
196+ if (tooltip .opacity == 0 )
197+ {
198+ sidebarToolWindow .hideTooltip ()
199+ }
200+ else if (tooltip .opacity == 1 )
201+ {
202+ sidebarToolWindow .showTooltip ()
203+ }
204+ }
205+ }
206+
184207 onPreSlicedDataChanged:
185208 {
186209 settingsVisible = UM .Preferences .getValue (" view/settings_visible" )
@@ -284,24 +307,42 @@ Item
284307 minimumHeight: Math .floor (1.5 * minimumWidth)
285308 height: minimumHeight
286309
310+ property string tooltipText
311+ function showTooltip ()
312+ {
313+ /* The divider automatically adapts to 100% of the parent width and
314+ wraps properly, so this causes the tooltips to be wrapped to the width
315+ of the tooltip as set by the operating system. */
316+ Tooltip .showText (printSetupWindow, Qt .point (printSetupWindow .mouseX , printSetupWindow .mouseY ), " <div>" + tooltipText + " </div>" )
317+ }
318+
319+ function hideTooltip ()
320+ {
321+ Tooltip .hideText ()
322+ }
323+
287324 visible: ! settingsDocked && settingsVisible
288325 onVisibleChanged:
289326 {
290327 if (visible)
291328 {
292329 printSetupWindow .children = [sidebarContents]
330+ printSetupTooltip .visible = false // hide vestigial tooltip in main window
293331 }
294332 else
295333 {
296334 printSetupSidebar .children = [sidebarContents]
335+ printSetupTooltip .visible = true
297336 }
298337 }
299338
300- Item
339+ MouseArea
301340 {
302341 id: printSetupWindow
303342
304343 anchors .fill : parent
344+ hoverEnabled: true
345+ acceptedButtons: Qt .NoButton
305346 }
306347 }
307348}
0 commit comments