ConfigurationItem.qml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.0
  5. import UM 1.2 as UM
  6. import Cura 1.0 as Cura
  7. Rectangle
  8. {
  9. id: configurationItem
  10. property var configuration: null
  11. property var selected: false
  12. signal activateConfiguration()
  13. height: childrenRect.height
  14. border.width: UM.Theme.getSize("default_lining").width
  15. border.color: updateBorderColor()
  16. color: selected ? UM.Theme.getColor("configuration_item_active") : UM.Theme.getColor("configuration_item")
  17. property var textColor: selected ? UM.Theme.getColor("configuration_item_text_active") : UM.Theme.getColor("configuration_item_text")
  18. function updateBorderColor()
  19. {
  20. border.color = selected ? UM.Theme.getColor("configuration_item_border_active") : UM.Theme.getColor("configuration_item_border")
  21. }
  22. Column
  23. {
  24. id: contentColumn
  25. width: parent.width
  26. padding: UM.Theme.getSize("default_margin").width
  27. spacing: Math.round(UM.Theme.getSize("default_margin").height / 2)
  28. Row
  29. {
  30. id: extruderRow
  31. width: parent.width - 2 * parent.padding
  32. height: childrenRect.height
  33. spacing: UM.Theme.getSize("default_margin").width
  34. Repeater
  35. {
  36. id: repeater
  37. height: childrenRect.height
  38. model: configuration.extruderConfigurations
  39. delegate: PrintCoreConfiguration
  40. {
  41. width: Math.round(parent.width / 2)
  42. printCoreConfiguration: modelData
  43. mainColor: textColor
  44. }
  45. }
  46. }
  47. //Buildplate row separator
  48. Rectangle
  49. {
  50. id: separator
  51. visible: buildplateInformation.visible
  52. width: parent.width - 2 * parent.padding
  53. height: visible ? Math.round(UM.Theme.getSize("sidebar_lining_thin").height / 2) : 0
  54. color: textColor
  55. }
  56. Item
  57. {
  58. id: buildplateInformation
  59. width: parent.width - 2 * parent.padding
  60. height: childrenRect.height
  61. visible: configuration.buildplateConfiguration != ""
  62. UM.RecolorImage {
  63. id: buildplateIcon
  64. anchors.left: parent.left
  65. width: UM.Theme.getSize("topbar_button_icon").width
  66. height: UM.Theme.getSize("topbar_button_icon").height
  67. sourceSize.width: width
  68. sourceSize.height: height
  69. source: UM.Theme.getIcon("buildplate")
  70. color: textColor
  71. }
  72. Label
  73. {
  74. id: buildplateLabel
  75. anchors.left: buildplateIcon.right
  76. anchors.verticalCenter: buildplateIcon.verticalCenter
  77. anchors.leftMargin: Math.round(UM.Theme.getSize("default_margin").height / 2)
  78. text: configuration.buildplateConfiguration
  79. renderType: Text.NativeRendering
  80. color: textColor
  81. }
  82. }
  83. }
  84. MouseArea
  85. {
  86. id: mouse
  87. anchors.fill: parent
  88. onClicked: activateConfiguration()
  89. hoverEnabled: true
  90. onEntered: parent.border.color = UM.Theme.getColor("configuration_item_border_hover")
  91. onExited: updateBorderColor()
  92. }
  93. Connections
  94. {
  95. target: Cura.MachineManager
  96. onCurrentConfigurationChanged: {
  97. configurationItem.selected = Cura.MachineManager.matchesConfiguration(configuration)
  98. updateBorderColor()
  99. }
  100. }
  101. Component.onCompleted:
  102. {
  103. configurationItem.selected = Cura.MachineManager.matchesConfiguration(configuration)
  104. updateBorderColor()
  105. }
  106. }