OutputDeviceHeader.qml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 2.1
  5. import UM 1.5 as UM
  6. import Cura 1.0 as Cura
  7. Item
  8. {
  9. implicitWidth: parent.width
  10. implicitHeight: Math.floor(childrenRect.height + UM.Theme.getSize("default_margin").height * 2)
  11. property var outputDevice: null
  12. Connections
  13. {
  14. target: Cura.MachineManager
  15. function onGlobalContainerChanged()
  16. {
  17. outputDevice = Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null;
  18. }
  19. }
  20. Rectangle
  21. {
  22. height: childrenRect.height
  23. color: UM.Theme.getColor("setting_category")
  24. UM.Label
  25. {
  26. id: outputDeviceNameLabel
  27. font: UM.Theme.getFont("large_bold")
  28. color: UM.Theme.getColor("text")
  29. anchors.left: parent.left
  30. anchors.top: parent.top
  31. anchors.margins: UM.Theme.getSize("default_margin").width
  32. text: outputDevice != null ? outputDevice.activePrinter.name : ""
  33. }
  34. UM.Label
  35. {
  36. id: outputDeviceAddressLabel
  37. text: (outputDevice != null && outputDevice.address != null) ? outputDevice.address : ""
  38. font: UM.Theme.getFont("default_bold")
  39. color: UM.Theme.getColor("text_inactive")
  40. anchors.top: outputDeviceNameLabel.bottom
  41. anchors.left: parent.left
  42. anchors.margins: UM.Theme.getSize("default_margin").width
  43. }
  44. UM.Label
  45. {
  46. text: outputDevice != null ? "" : catalog.i18nc("@info:status", "The printer is not connected.")
  47. color: outputDevice != null && outputDevice.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  48. wrapMode: Text.WordWrap
  49. anchors.left: parent.left
  50. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  51. anchors.right: parent.right
  52. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  53. anchors.top: parent.top
  54. anchors.topMargin: UM.Theme.getSize("default_margin").height
  55. }
  56. }
  57. }