PrintSelectorCard.qml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.9
  5. import QtQuick.Layouts 2.10
  6. import UM 1.5 as UM
  7. import Cura 1.0 as Cura
  8. Rectangle
  9. {
  10. property alias name: printerTitle.text
  11. property string unique_id
  12. property var extruders
  13. property var manager
  14. width: parent.width
  15. height: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height
  16. color: UM.Theme.getColor("background_1")
  17. border.color: UM.Theme.getColor("border_main")
  18. border.width: UM.Theme.getSize("default_lining").width
  19. RowLayout
  20. {
  21. anchors.left: parent.left
  22. anchors.right: parent.right
  23. anchors.top: parent.top
  24. anchors.margins: UM.Theme.getSize("default_margin").width
  25. Cura.IconWithText
  26. {
  27. id: printerTitle
  28. Layout.preferredWidth: parent.width / 3
  29. Layout.fillWidth: true
  30. Layout.alignment: extruders[0].materials.length > 1 ? Qt.AlignTop: Qt.AlignCenter
  31. Layout.fillHeight: false
  32. source: UM.Theme.getIcon("Printer")
  33. spacing: UM.Theme.getSize("thin_margin").width
  34. iconSize: UM.Theme.getSize("medium_button_icon").width
  35. font: UM.Theme.getFont("medium_bold")
  36. }
  37. ColumnLayout
  38. {
  39. id: extruderInformation
  40. Layout.fillWidth: true
  41. Layout.preferredWidth: parent.width / 2
  42. Layout.alignment: Qt.AlignTop
  43. spacing: UM.Theme.getSize("narrow_margin").width
  44. Repeater
  45. {
  46. model: extruders
  47. Item
  48. {
  49. height: childrenRect.height
  50. Cura.ExtruderIcon
  51. {
  52. id: extruderIcon
  53. anchors.top: parent.top
  54. anchors.left: parent.left
  55. materialColor: modelData.materials.length == 1 ? modelData.materials[0].hexcolor : "white"
  56. iconSize: UM.Theme.getSize("medium_button_icon").width
  57. }
  58. UM.Label
  59. {
  60. id: extruderCore
  61. anchors.verticalCenter: extruderIcon.verticalCenter
  62. anchors.left: extruderIcon.right
  63. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  64. text: modelData.core
  65. font: UM.Theme.getFont("default_bold")
  66. }
  67. UM.Label
  68. {
  69. id: singleMaterialText
  70. anchors.left: extruderCore.right
  71. anchors.verticalCenter: extruderCore.verticalCenter
  72. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  73. text: modelData.materials.length == 1 ? `${modelData.materials[0].brand} ${modelData.materials[0].name}` : ""
  74. visible: modelData.materials.length == 1
  75. }
  76. ColumnLayout
  77. {
  78. id: multiMaterialText
  79. anchors.top: extruderCore.bottom
  80. anchors.left: extruderCore.left
  81. anchors.topMargin: UM.Theme.getSize("narrow_margin").height
  82. visible: modelData.materials.length > 1
  83. Repeater
  84. {
  85. model: modelData.materials.length > 1 ? modelData.materials: null
  86. UM.Label
  87. {
  88. text: `${modelData.brand} ${modelData.name}`
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. Button
  96. {
  97. id: printButton
  98. implicitWidth: UM.Theme.getSize("large_button").width
  99. implicitHeight: implicitWidth
  100. Layout.alignment: extruders[0].materials.length > 1 ? Qt.AlignTop: Qt.AlignCenter
  101. padding: 0
  102. background: Rectangle
  103. {
  104. border.width: UM.Theme.getSize("default_lining").width
  105. border.color: UM.Theme.getColor("border_accent_1")
  106. color: printButton.hovered ? UM.Theme.getColor("toolbar_button_hover"): UM.Theme.getColor("background_1")
  107. }
  108. contentItem: Item
  109. {
  110. UM.ColorImage
  111. {
  112. anchors.centerIn: parent
  113. source: UM.Theme.getIcon("Printer")
  114. color: UM.Theme.getColor("border_accent_1")
  115. width: UM.Theme.getSize("medium_button_icon").width
  116. height: width
  117. }
  118. }
  119. onClicked: manager.printerSelected(unique_id)
  120. }
  121. }
  122. }