PrintSetupTooltip.qml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.3
  5. import UM 1.0 as UM
  6. UM.PointingRectangle {
  7. id: base;
  8. width: UM.Theme.getSize("tooltip").width;
  9. height: label.height + UM.Theme.getSize("tooltip_margins").height * 2;
  10. color: UM.Theme.getColor("tooltip");
  11. arrowSize: UM.Theme.getSize("default_arrow").width
  12. opacity: 0;
  13. Behavior on opacity { NumberAnimation { duration: 100; } }
  14. property alias text: label.text;
  15. function show(position) {
  16. if(position.y + base.height > parent.height) {
  17. x = position.x - base.width;
  18. y = parent.height - base.height;
  19. } else {
  20. x = position.x - base.width;
  21. y = position.y - UM.Theme.getSize("tooltip_arrow_margins").height;
  22. if(y < 0)
  23. {
  24. position.y += -y;
  25. y = 0;
  26. }
  27. }
  28. base.opacity = 1;
  29. target = Qt.point(position.x + 1, position.y + Math.round(UM.Theme.getSize("tooltip_arrow_margins").height / 2))
  30. }
  31. function hide() {
  32. base.opacity = 0;
  33. }
  34. Label
  35. {
  36. id: label;
  37. anchors {
  38. top: parent.top;
  39. topMargin: UM.Theme.getSize("tooltip_margins").height;
  40. left: parent.left;
  41. leftMargin: UM.Theme.getSize("tooltip_margins").width;
  42. right: parent.right;
  43. rightMargin: UM.Theme.getSize("tooltip_margins").width;
  44. }
  45. wrapMode: Text.Wrap;
  46. textFormat: Text.RichText
  47. font: UM.Theme.getFont("default");
  48. color: UM.Theme.getColor("tooltip_text");
  49. renderType: Text.NativeRendering
  50. }
  51. }