PrintSelectorCard.qml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.preferredHeight: childrenRect.height
  30. Layout.fillWidth: true
  31. Layout.alignment: extruders[0].materials.length > 1 ? Qt.AlignTop : Qt.AlignCenter
  32. Layout.fillHeight: false
  33. source: UM.Theme.getIcon("Printer")
  34. spacing: UM.Theme.getSize("thin_margin").width
  35. iconSize: UM.Theme.getSize("medium_button_icon").width
  36. font: UM.Theme.getFont("medium_bold")
  37. }
  38. Column
  39. {
  40. id: extruderInformation
  41. Layout.fillWidth: true
  42. Layout.preferredWidth: parent.width / 2
  43. Layout.preferredHeight: childrenRect.height
  44. Layout.alignment: extruders[0].materials.length > 1 ? Qt.AlignTop : Qt.AlignCenter
  45. spacing: UM.Theme.getSize("narrow_margin").height
  46. Repeater
  47. {
  48. model: extruders
  49. Item
  50. {
  51. width: extruderInformation.width
  52. height: childrenRect.height
  53. Cura.ExtruderIcon
  54. {
  55. id: extruderIcon
  56. anchors.top: parent.top
  57. anchors.left: parent.left
  58. materialColor: modelData.materials.length == 1 ? modelData.materials[0].hexcolor : "white"
  59. iconSize: UM.Theme.getSize("medium_button_icon").width
  60. }
  61. UM.Label
  62. {
  63. id: extruderCore
  64. anchors.verticalCenter: extruderIcon.verticalCenter
  65. anchors.left: extruderIcon.right
  66. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  67. text: modelData ? (modelData.core ? modelData.core : "" ) : ""
  68. font: UM.Theme.getFont("default_bold")
  69. }
  70. UM.Label
  71. {
  72. id: singleMaterialText
  73. anchors.left: extruderCore.right
  74. anchors.right: parent.right
  75. anchors.verticalCenter: extruderCore.verticalCenter
  76. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  77. text: modelData.materials.length == 1 ? `${modelData.materials[0].brand} ${modelData.materials[0].name}` : ""
  78. visible: modelData.materials.length == 1
  79. }
  80. ColumnLayout
  81. {
  82. id: multiMaterialText
  83. anchors.top: extruderCore.bottom
  84. anchors.left: extruderCore.left
  85. anchors.topMargin: UM.Theme.getSize("narrow_margin").height
  86. visible: modelData.materials.length > 1
  87. Repeater
  88. {
  89. model: modelData.materials.length > 1 ? modelData.materials: null
  90. UM.Label
  91. {
  92. text: `${modelData.brand} ${modelData.name}`
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. Button
  100. {
  101. id: printButton
  102. implicitWidth: UM.Theme.getSize("large_button").width
  103. implicitHeight: implicitWidth
  104. Layout.alignment: extruders[0].materials.length > 1 ? Qt.AlignTop : Qt.AlignCenter
  105. Layout.preferredHeight: childrenRect.height
  106. padding: 0
  107. background: Rectangle
  108. {
  109. border.width: UM.Theme.getSize("default_lining").width
  110. border.color: UM.Theme.getColor("border_accent_1")
  111. color: printButton.hovered ? UM.Theme.getColor("toolbar_button_hover"): UM.Theme.getColor("background_1")
  112. }
  113. contentItem: Item
  114. {
  115. UM.ColorImage
  116. {
  117. anchors.centerIn: parent
  118. source: UM.Theme.getIcon("Printer")
  119. color: UM.Theme.getColor("border_accent_1")
  120. width: UM.Theme.getSize("medium_button_icon").width
  121. height: width
  122. }
  123. }
  124. onClicked: manager.printerSelected(unique_id)
  125. }
  126. }
  127. }