SidebarTooltip.qml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.0 as UM
  8. Rectangle {
  9. id: base;
  10. width: UM.Theme.sizes.tooltip.width;
  11. height: label.height + UM.Theme.sizes.tooltip_margins.height * 2;
  12. color: UM.Theme.colors.tooltip;
  13. opacity: 0;
  14. Behavior on opacity { NumberAnimation { duration: 100; } }
  15. property alias text: label.text;
  16. function show(position) {
  17. if(position.y + base.height > parent.height) {
  18. x = position.x;
  19. y = parent.height - base.height;
  20. } else {
  21. x = position.x;
  22. y = position.y;
  23. }
  24. base.opacity = 1;
  25. }
  26. function hide() {
  27. base.opacity = 0;
  28. }
  29. Label {
  30. id: label;
  31. anchors {
  32. top: parent.top;
  33. topMargin: UM.Theme.sizes.tooltip_margins.height;
  34. left: parent.left;
  35. leftMargin: UM.Theme.sizes.tooltip_margins.width;
  36. right: parent.right;
  37. rightMargin: UM.Theme.sizes.tooltip_margins.width;
  38. }
  39. wrapMode: Text.Wrap;
  40. font: UM.Theme.fonts.default;
  41. }
  42. }