MonitorPrinterPill.qml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.4
  5. import UM 1.2 as UM
  6. /**
  7. * A MonitorPrinterPill is a blue-colored tag indicating which printers a print
  8. * job is compatible with. It is used by the MonitorPrintJobCard component.
  9. */
  10. Item
  11. {
  12. // The printer name
  13. property var text: ""
  14. property var tagText: {
  15. switch(text) {
  16. case "Ultimaker 3":
  17. return "UM 3"
  18. case "Ultimaker 3 Extended":
  19. return "UM 3 EXT"
  20. case "Ultimaker S5":
  21. return "UM S5"
  22. default:
  23. return text
  24. }
  25. }
  26. implicitHeight: 18 * screenScaleFactor // TODO: Theme!
  27. implicitWidth: Math.max(printerNameLabel.contentWidth + 12 * screenScaleFactor, 36 * screenScaleFactor) // TODO: Theme!
  28. Rectangle {
  29. id: background
  30. anchors.fill: parent
  31. color: printerNameLabel.visible ? UM.Theme.getColor("monitor_printer_family_tag") : UM.Theme.getColor("monitor_skeleton_loading")
  32. radius: 2 * screenScaleFactor // TODO: Theme!
  33. }
  34. Label {
  35. id: printerNameLabel
  36. anchors.centerIn: parent
  37. color: UM.Theme.getColor("monitor_text_primary")
  38. text: tagText
  39. font.pointSize: 10 // TODO: Theme!
  40. visible: text !== ""
  41. renderType: Text.NativeRendering
  42. }
  43. }