Browse Source

Added Tooltip alignment
CURA-6004

Aleksei S 6 years ago
parent
commit
3953c7bb3a

+ 2 - 0
resources/qml/ActionButton.qml

@@ -31,6 +31,8 @@ Button
     property alias shadowColor: shadow.color
     property alias shadowColor: shadow.color
     property alias shadowEnabled: shadow.visible
     property alias shadowEnabled: shadow.visible
 
 
+    property alias toolTipContentAlignment: tooltip.contentAlignment
+
     // This property is used to indicate whether the button has a fixed width or the width would depend on the contents
     // This property is used to indicate whether the button has a fixed width or the width would depend on the contents
     // Be careful when using fixedWidthMode, the translated texts can be too long that they won't fit. In any case,
     // Be careful when using fixedWidthMode, the translated texts can be too long that they won't fit. In any case,
     // we elide the text to the right so the text will be cut off with the three dots at the end.
     // we elide the text to the right so the text will be cut off with the three dots at the end.

+ 2 - 0
resources/qml/ActionPanel/OutputProcessWidget.qml

@@ -123,6 +123,8 @@ Column
             tooltip: text
             tooltip: text
             fixedWidthMode: true
             fixedWidthMode: true
 
 
+            toolTipContentAlignment: Cura.ToolTip.ContentAlignment.AlignLeft
+
             onClicked: UM.Controller.setActiveStage("PreviewStage")
             onClicked: UM.Controller.setActiveStage("PreviewStage")
             visible: UM.Controller.activeStage != null && UM.Controller.activeStage.stageId != "PreviewStage"
             visible: UM.Controller.activeStage != null && UM.Controller.activeStage.stageId != "PreviewStage"
 
 

+ 26 - 3
resources/qml/ToolTip.qml

@@ -5,14 +5,26 @@ import QtQuick 2.7
 import QtQuick.Controls 2.3
 import QtQuick.Controls 2.3
 
 
 import UM 1.0 as UM
 import UM 1.0 as UM
+import Cura 1.0 as Cura
 
 
 ToolTip
 ToolTip
 {
 {
+
+    enum ContentAlignment
+    {
+        AlignLeft,
+        AlignRight
+    }
+
     // This property indicates when the tooltip has to show, for instance when a button is hovered
     // This property indicates when the tooltip has to show, for instance when a button is hovered
     property bool show: false
     property bool show: false
 
 
+    // Defines the alignment of the content, by default to the left
+    property int contentAlignment: Cura.ToolTip.ContentAlignment.AlignRight
+
     property alias tooltipText: tooltip.text
     property alias tooltipText: tooltip.text
-    property var targetPoint: Qt.point(0, 0)
+    property var targetPoint: Qt.point(parent.x, y + Math.round(height/2))
+
 
 
     id: tooltip
     id: tooltip
     text: ""
     text: ""
@@ -20,13 +32,24 @@ ToolTip
     visible: text != "" && show
     visible: text != "" && show
     font: UM.Theme.getFont("default")
     font: UM.Theme.getFont("default")
 
 
+    x:
+    {
+        if (contentAlignment == Cura.ToolTip.ContentAlignment.AlignLeft)
+        {
+            return (label.width + Math.round(UM.Theme.getSize("default_arrow").width * 1.2) + padding * 2) * -1
+        }
+        return parent.width + Math.round(UM.Theme.getSize("default_arrow").width * 1.2 + padding)
+    }
+
+    y: Math.round(parent.height / 2 - label.height / 2 ) - padding
+
+    padding: 2
+
     background: UM.PointingRectangle
     background: UM.PointingRectangle
     {
     {
         id: backgroundRect
         id: backgroundRect
         color: UM.Theme.getColor("tooltip")
         color: UM.Theme.getColor("tooltip")
-
         target: Qt.point(targetPoint.x - tooltip.x, targetPoint.y - tooltip.y)
         target: Qt.point(targetPoint.x - tooltip.x, targetPoint.y - tooltip.y)
-
         arrowSize: UM.Theme.getSize("default_arrow").width
         arrowSize: UM.Theme.getSize("default_arrow").width
     }
     }