PrintSelectorCard.qml 5.0 KB

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