OutputDeviceHeader.qml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. anchors.left: parent.left
  29. anchors.top: parent.top
  30. anchors.margins: UM.Theme.getSize("default_margin").width
  31. text: outputDevice != null ? outputDevice.activePrinter.name : ""
  32. }
  33. UM.Label
  34. {
  35. id: outputDeviceAddressLabel
  36. text: (outputDevice != null && outputDevice.address != null) ? outputDevice.address : ""
  37. font: UM.Theme.getFont("default_bold")
  38. color: UM.Theme.getColor("text_inactive")
  39. anchors.top: outputDeviceNameLabel.bottom
  40. anchors.left: parent.left
  41. anchors.margins: UM.Theme.getSize("default_margin").width
  42. }
  43. UM.Label
  44. {
  45. text: outputDevice != null ? "" : catalog.i18nc("@info:status", "The printer is not connected.")
  46. color: outputDevice != null && outputDevice.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  47. wrapMode: Text.WordWrap
  48. anchors.left: parent.left
  49. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  50. anchors.right: parent.right
  51. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  52. anchors.top: parent.top
  53. anchors.topMargin: UM.Theme.getSize("default_margin").height
  54. }
  55. }
  56. }