PrintSetupTooltip.qml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. id: label;
  36. anchors {
  37. top: parent.top;
  38. topMargin: UM.Theme.getSize("tooltip_margins").height;
  39. left: parent.left;
  40. leftMargin: UM.Theme.getSize("tooltip_margins").width;
  41. right: parent.right;
  42. rightMargin: UM.Theme.getSize("tooltip_margins").width;
  43. }
  44. wrapMode: Text.Wrap;
  45. textFormat: Text.RichText
  46. font: UM.Theme.getFont("default");
  47. color: UM.Theme.getColor("tooltip_text");
  48. renderType: Text.NativeRendering
  49. }
  50. }