SliceProcessWidget.qml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.1
  5. import QtQuick.Layouts 1.3
  6. import QtQuick.Controls 1.4 as Controls1
  7. import UM 1.1 as UM
  8. import Cura 1.0 as Cura
  9. // This element contains all the elements the user needs to create a printjob from the
  10. // model(s) that is(are) on the buildplate. Mainly the button to start/stop the slicing
  11. // process and a progress bar to see the progress of the process.
  12. Column
  13. {
  14. id: widget
  15. spacing: UM.Theme.getSize("thin_margin").height
  16. UM.I18nCatalog
  17. {
  18. id: catalog
  19. name: "cura"
  20. }
  21. property real progress: UM.Backend.progress
  22. property int backendState: UM.Backend.state
  23. function sliceOrStopSlicing()
  24. {
  25. if (widget.backendState == UM.Backend.NotStarted)
  26. {
  27. CuraApplication.backend.forceSlice()
  28. }
  29. else
  30. {
  31. CuraApplication.backend.stopSlicing()
  32. }
  33. }
  34. Label
  35. {
  36. id: autoSlicingLabel
  37. width: parent.width
  38. visible: progressBar.visible
  39. text: catalog.i18nc("@label:PrintjobStatus", "Slicing...")
  40. color: UM.Theme.getColor("text")
  41. font: UM.Theme.getFont("default")
  42. renderType: Text.NativeRendering
  43. }
  44. Cura.IconWithText
  45. {
  46. id: unableToSliceMessage
  47. width: parent.width
  48. visible: widget.backendState == UM.Backend.Error
  49. text: catalog.i18nc("@label:PrintjobStatus", "Unable to Slice")
  50. source: UM.Theme.getIcon("warning")
  51. iconColor: UM.Theme.getColor("warning")
  52. }
  53. // Progress bar, only visible when the backend is in the process of slice the printjob
  54. Cura.ProgressBar
  55. {
  56. id: progressBar
  57. width: parent.width
  58. height: UM.Theme.getSize("progressbar").height
  59. value: progress
  60. indeterminate: widget.backendState == UM.Backend.NotStarted
  61. visible: (widget.backendState == UM.Backend.Processing || (prepareButtons.autoSlice && widget.backendState == UM.Backend.NotStarted))
  62. }
  63. Item
  64. {
  65. id: prepareButtons
  66. // Get the current value from the preferences
  67. property bool autoSlice: UM.Preferences.getValue("general/auto_slice")
  68. // Disable the slice process when
  69. width: parent.width
  70. height: UM.Theme.getSize("action_button").height
  71. visible: !autoSlice
  72. Cura.PrimaryButton
  73. {
  74. id: sliceButton
  75. fixedWidthMode: true
  76. height: parent.height
  77. anchors.right: parent.right
  78. anchors.left: parent.left
  79. text: catalog.i18nc("@button", "Slice")
  80. tooltip: catalog.i18nc("@label", "Start the slicing process")
  81. enabled: widget.backendState != UM.Backend.Error
  82. visible: widget.backendState == UM.Backend.NotStarted || widget.backendState == UM.Backend.Error
  83. onClicked: sliceOrStopSlicing()
  84. }
  85. Cura.SecondaryButton
  86. {
  87. id: cancelButton
  88. fixedWidthMode: true
  89. height: parent.height
  90. anchors.left: parent.left
  91. anchors.right: parent.right
  92. text: catalog.i18nc("@button", "Cancel")
  93. enabled: sliceButton.enabled
  94. visible: !sliceButton.visible
  95. onClicked: sliceOrStopSlicing()
  96. }
  97. }
  98. // React when the user changes the preference of having the auto slice enabled
  99. Connections
  100. {
  101. target: UM.Preferences
  102. onPreferenceChanged:
  103. {
  104. if (preference !== "general/auto_slice")
  105. {
  106. return;
  107. }
  108. var autoSlice = UM.Preferences.getValue("general/auto_slice")
  109. if(prepareButtons.autoSlice != autoSlice)
  110. {
  111. prepareButtons.autoSlice = autoSlice
  112. if(autoSlice)
  113. {
  114. CuraApplication.backend.forceSlice()
  115. }
  116. }
  117. }
  118. }
  119. // Shortcut for "slice/stop"
  120. Controls1.Action
  121. {
  122. shortcut: "Ctrl+P"
  123. onTriggered:
  124. {
  125. if (sliceButton.enabled)
  126. {
  127. sliceOrStopSlicing()
  128. }
  129. }
  130. }
  131. }