From 8d0a31dcfb3d865b8f1fd7668d05ad11b80332bc Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 29 Apr 2019 10:33:02 +0200 Subject: [PATCH 1/3] Show tooltip on the right side if the setting area is to far to the left CURA-6478 --- resources/qml/Cura.qml | 1 + resources/qml/PrintSetupTooltip.qml | 51 ++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index e640b25b24..12630239ab 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -391,6 +391,7 @@ UM.MainWindow PrintSetupTooltip { id: tooltip + sourceWidth: UM.Theme.getSize("print_setup_widget").width } } diff --git a/resources/qml/PrintSetupTooltip.qml b/resources/qml/PrintSetupTooltip.qml index 6b1538d849..41d68aef37 100644 --- a/resources/qml/PrintSetupTooltip.qml +++ b/resources/qml/PrintSetupTooltip.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Ultimaker B.V. +// Copyright (c) 2019 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -6,26 +6,43 @@ import QtQuick.Controls 2.3 import UM 1.0 as UM -UM.PointingRectangle { - id: base; - - width: UM.Theme.getSize("tooltip").width; - height: label.height + UM.Theme.getSize("tooltip_margins").height * 2; - color: UM.Theme.getColor("tooltip"); +UM.PointingRectangle +{ + id: base + property real sourceWidth: 0 + width: UM.Theme.getSize("tooltip").width + height: label.height + UM.Theme.getSize("tooltip_margins").height * 2 + color: UM.Theme.getColor("tooltip") arrowSize: UM.Theme.getSize("default_arrow").width - opacity: 0; - Behavior on opacity { NumberAnimation { duration: 100; } } + opacity: 0 - property alias text: label.text; + Behavior on opacity + { + NumberAnimation { duration: 100; } + } - function show(position) { - if(position.y + base.height > parent.height) { + property alias text: label.text + + function show(position) + { + if(position.y + base.height > parent.height) + { x = position.x - base.width; y = parent.height - base.height; - } else { - x = position.x - base.width; + } else + { + var new_x = x = position.x - base.width + + // If the tooltip would fall out of the screen, display it on the other side. + if(new_x < 0) + { + new_x = x + sourceWidth + base.width + } + + x = new_x + y = position.y - UM.Theme.getSize("tooltip_arrow_margins").height; if(y < 0) { @@ -37,14 +54,16 @@ UM.PointingRectangle { target = Qt.point(position.x + 1, position.y + Math.round(UM.Theme.getSize("tooltip_arrow_margins").height / 2)) } - function hide() { + function hide() + { base.opacity = 0; } Label { id: label; - anchors { + anchors + { top: parent.top; topMargin: UM.Theme.getSize("tooltip_margins").height; left: parent.left; From db1a5ec8c0646f694145dd142ba391257bd6e625 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 29 Apr 2019 10:38:05 +0200 Subject: [PATCH 2/3] Add mousearea to prevent clicking through the printSetupSelector CURA-6478 --- resources/qml/Cura.qml | 2 +- .../qml/PrintSetupSelector/PrintSetupSelectorContents.qml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 12630239ab..b6d62ec3f0 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -391,7 +391,7 @@ UM.MainWindow PrintSetupTooltip { id: tooltip - sourceWidth: UM.Theme.getSize("print_setup_widget").width + sourceWidth: UM.Theme.getSize("print_setup_widget").width } } diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index 3b090f7476..b1e8cc05d8 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -25,6 +25,13 @@ Item Custom = 1 } + // Catch all mouse events + MouseArea + { + anchors.fill: parent + hoverEnabled: true + } + // Set the current mode index to the value that is stored in the preferences or Recommended mode otherwise. property int currentModeIndex: { From 79fbe12e9203eb52f58217591cd5d097e8b3797c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 29 Apr 2019 10:49:33 +0200 Subject: [PATCH 3/3] Add an extra check to enforce min height of printSetupSelector CURA-6478 --- .../qml/PrintSetupSelector/PrintSetupSelectorContents.qml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index b1e8cc05d8..b377d2c96b 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -201,7 +201,13 @@ Item { h -= mouse_absolute_y - base.height; } - + // Enforce a minimum size (again). + // This is a bit of a hackish way to do it, but we've seen some ocasional reports that the size + // could get below the the minimum height. + if(h < absoluteMinimumHeight) + { + h = absoluteMinimumHeight; + } UM.Preferences.setValue("view/settings_list_height", h); } }