RecommendedAdhesionSelector.qml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.2 as UM
  7. import Cura 1.0 as Cura
  8. //
  9. // Adhesion
  10. //
  11. Item
  12. {
  13. id: enableAdhesionRow
  14. height: childrenRect.height
  15. property real labelColumnWidth: Math.round(width / 3)
  16. Cura.IconWithText
  17. {
  18. id: enableAdhesionRowTitle
  19. anchors.top: parent.top
  20. anchors.left: parent.left
  21. source: UM.Theme.getIcon("category_adhesion")
  22. text: catalog.i18nc("@label", "Adhesion")
  23. font: UM.Theme.getFont("medium")
  24. width: labelColumnWidth
  25. }
  26. Item
  27. {
  28. id: enableAdhesionContainer
  29. height: enableAdhesionCheckBox.height
  30. anchors
  31. {
  32. left: enableAdhesionRowTitle.right
  33. right: parent.right
  34. verticalCenter: enableAdhesionRowTitle.verticalCenter
  35. }
  36. CheckBox
  37. {
  38. id: enableAdhesionCheckBox
  39. anchors.verticalCenter: parent.verticalCenter
  40. property alias _hovered: adhesionMouseArea.containsMouse
  41. //: Setting enable printing build-plate adhesion helper checkbox
  42. style: UM.Theme.styles.checkbox
  43. enabled: recommendedPrintSetup.settingsEnabled
  44. visible: platformAdhesionType.properties.enabled == "True"
  45. checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none"
  46. MouseArea
  47. {
  48. id: adhesionMouseArea
  49. anchors.fill: parent
  50. hoverEnabled: true
  51. onClicked:
  52. {
  53. var adhesionType = "skirt"
  54. if (!parent.checked)
  55. {
  56. // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft
  57. platformAdhesionType.removeFromContainer(0)
  58. adhesionType = platformAdhesionType.properties.value
  59. if(adhesionType == "skirt" || adhesionType == "none")
  60. {
  61. // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim
  62. adhesionType = "brim"
  63. }
  64. }
  65. platformAdhesionType.setPropertyValue("value", adhesionType)
  66. }
  67. onEntered:
  68. {
  69. base.showTooltip(enableAdhesionCheckBox, Qt.point(-enableAdhesionContainer.x - UM.Theme.getSize("thick_margin").width, 0),
  70. catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards."));
  71. }
  72. onExited: base.hideTooltip()
  73. }
  74. }
  75. }
  76. UM.SettingPropertyProvider
  77. {
  78. id: platformAdhesionType
  79. containerStack: Cura.MachineManager.activeMachine
  80. removeUnusedValue: false //Doesn't work with settings that are resolved.
  81. key: "adhesion_type"
  82. watchedProperties: [ "value", "enabled" ]
  83. storeIndex: 0
  84. }
  85. }