ExtruderButton.qml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import UM 1.2 as UM
  6. import Cura 1.0 as Cura
  7. Button
  8. {
  9. id: base
  10. property var extruder;
  11. text: catalog.i18ncp("@label %1 is filled in with the name of an extruder", "Print Selected Model with %1", "Print Selected Models with %1", UM.Selection.selectionCount).arg(extruder.name)
  12. style: UM.Theme.styles.tool_button;
  13. iconSource: UM.Theme.getIcon("extruder_button")
  14. checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1
  15. enabled: UM.Selection.hasSelection && extruder.stack.isEnabled
  16. property color customColor: base.hovered ? UM.Theme.getColor("button_hover") : UM.Theme.getColor("button");
  17. Rectangle
  18. {
  19. anchors.fill: parent
  20. anchors.margins: UM.Theme.getSize("default_lining").width;
  21. color: "transparent"
  22. border.width: base.checked ? UM.Theme.getSize("default_lining").width : 0;
  23. border.color: UM.Theme.getColor("button_text")
  24. }
  25. Item
  26. {
  27. anchors.centerIn: parent
  28. width: UM.Theme.getSize("default_margin").width
  29. height: UM.Theme.getSize("default_margin").height
  30. Label
  31. {
  32. anchors.centerIn: parent;
  33. text: index + 1;
  34. color: parent.enabled ? UM.Theme.getColor("button_text") : UM.Theme.getColor("button_disabled_text")
  35. font: UM.Theme.getFont("default_bold");
  36. }
  37. }
  38. // Material colour circle
  39. // Only draw the filling colour of the material inside the SVG border.
  40. Rectangle
  41. {
  42. anchors
  43. {
  44. right: parent.right
  45. top: parent.top
  46. rightMargin: UM.Theme.getSize("extruder_button_material_margin").width
  47. topMargin: UM.Theme.getSize("extruder_button_material_margin").height
  48. }
  49. color: model.color
  50. width: UM.Theme.getSize("extruder_button_material").width
  51. height: UM.Theme.getSize("extruder_button_material").height
  52. radius: Math.round(width / 2)
  53. border.width: UM.Theme.getSize("default_lining").width
  54. border.color: UM.Theme.getColor("extruder_button_material_border")
  55. opacity: !base.enabled ? 0.2 : 1.0
  56. }
  57. onClicked:
  58. {
  59. forceActiveFocus() //First grab focus, so all the text fields are updated
  60. CuraActions.setExtruderForSelection(extruder.id);
  61. }
  62. }