JobSpecs.qml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.1 as UM
  8. import Cura 1.0 as Cura
  9. Rectangle {
  10. id: base
  11. property bool activity: Printer.getPlatformActivity
  12. property string fileBaseName
  13. property variant activeMachineName: Cura.MachineManager.activeMachineName
  14. onActiveMachineNameChanged:
  15. {
  16. printJobTextfield.text = PrintInformation.createJobName(base.fileBaseName);
  17. }
  18. UM.I18nCatalog { id: catalog; name:"cura"}
  19. property variant printDuration: PrintInformation.currentPrintTime
  20. property variant printMaterialAmounts: PrintInformation.materialAmounts
  21. height: childrenRect.height
  22. color: "transparent"
  23. Connections
  24. {
  25. target: backgroundItem
  26. onHasMesh:
  27. {
  28. base.fileBaseName = name
  29. }
  30. }
  31. onActivityChanged: {
  32. if (activity == true && base.fileBaseName == ''){
  33. //this only runs when you open a file from the terminal (or something that works the same way; for example when you drag a file on the icon in MacOS or use 'open with' on Windows)
  34. base.fileBaseName = PrintInformation.jobName; //get the fileBaseName from PrintInformation.py because this saves the filebase when the file is opened using the terminal (or something alike)
  35. printJobTextfield.text = PrintInformation.createJobName(base.fileBaseName);
  36. }
  37. if (activity == true && base.fileBaseName != ''){
  38. //this runs in all other cases where there is a mesh on the buildplate (activity == true). It uses the fileBaseName from the hasMesh signal
  39. printJobTextfield.text = PrintInformation.createJobName(base.fileBaseName);
  40. }
  41. if (activity == false){
  42. //When there is no mesh in the buildplate; the printJobTextField is set to an empty string so it doesn't set an empty string as a jobName (which is later used for saving the file)
  43. printJobTextfield.text = '';
  44. }
  45. }
  46. Rectangle
  47. {
  48. id: jobNameRow
  49. anchors.top: parent.top
  50. anchors.right: parent.right
  51. height: UM.Theme.getSize("jobspecs_line").height
  52. visible: base.activity
  53. Item
  54. {
  55. width: parent.width
  56. height: parent.height
  57. Button
  58. {
  59. id: printJobPencilIcon
  60. anchors.right: parent.right
  61. anchors.verticalCenter: parent.verticalCenter
  62. width: UM.Theme.getSize("save_button_specs_icons").width
  63. height: UM.Theme.getSize("save_button_specs_icons").height
  64. onClicked:
  65. {
  66. printJobTextfield.selectAll();
  67. printJobTextfield.focus = true;
  68. }
  69. style: ButtonStyle
  70. {
  71. background: Rectangle
  72. {
  73. color: "transparent"
  74. UM.RecolorImage
  75. {
  76. width: UM.Theme.getSize("save_button_specs_icons").width;
  77. height: UM.Theme.getSize("save_button_specs_icons").height;
  78. sourceSize.width: width;
  79. sourceSize.height: width;
  80. color: control.hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("text");
  81. source: UM.Theme.getIcon("pencil");
  82. }
  83. }
  84. }
  85. }
  86. TextField
  87. {
  88. id: printJobTextfield
  89. anchors.right: printJobPencilIcon.left
  90. anchors.rightMargin: UM.Theme.getSize("default_margin").width/2
  91. height: UM.Theme.getSize("jobspecs_line").height
  92. width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50)
  93. maximumLength: 120
  94. property int unremovableSpacing: 5
  95. text: ''
  96. horizontalAlignment: TextInput.AlignRight
  97. onTextChanged: {
  98. PrintInformation.setJobName(text);
  99. }
  100. onEditingFinished: {
  101. if (printJobTextfield.text != ''){
  102. printJobTextfield.focus = false;
  103. }
  104. }
  105. validator: RegExpValidator {
  106. regExp: /^[^\\ \/ \*\?\|\[\]]*$/
  107. }
  108. style: TextFieldStyle{
  109. textColor: UM.Theme.getColor("setting_control_text");
  110. font: UM.Theme.getFont("default_bold");
  111. background: Rectangle {
  112. opacity: 0
  113. border.width: 0
  114. }
  115. }
  116. }
  117. }
  118. }
  119. Label{
  120. id: boundingSpec
  121. anchors.top: jobNameRow.bottom
  122. anchors.right: parent.right
  123. height: UM.Theme.getSize("jobspecs_line").height
  124. verticalAlignment: Text.AlignVCenter
  125. font: UM.Theme.getFont("small")
  126. color: UM.Theme.getColor("text_subtext")
  127. text: Printer.getSceneBoundingBoxString
  128. }
  129. Rectangle {
  130. id: specsRow
  131. anchors.top: boundingSpec.bottom
  132. anchors.right: parent.right
  133. height: UM.Theme.getSize("jobspecs_line").height
  134. Item{
  135. width: parent.width
  136. height: parent.height
  137. UM.RecolorImage {
  138. id: timeIcon
  139. anchors.right: timeSpec.left
  140. anchors.rightMargin: UM.Theme.getSize("default_margin").width/2
  141. anchors.verticalCenter: parent.verticalCenter
  142. width: UM.Theme.getSize("save_button_specs_icons").width
  143. height: UM.Theme.getSize("save_button_specs_icons").height
  144. sourceSize.width: width
  145. sourceSize.height: width
  146. color: UM.Theme.getColor("text_subtext")
  147. source: UM.Theme.getIcon("print_time")
  148. }
  149. Label{
  150. id: timeSpec
  151. anchors.right: lengthIcon.left
  152. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  153. anchors.verticalCenter: parent.verticalCenter
  154. font: UM.Theme.getFont("small")
  155. color: UM.Theme.getColor("text_subtext")
  156. text: (!base.printDuration || !base.printDuration.valid) ? catalog.i18nc("@label", "00h 00min") : base.printDuration.getDisplayString(UM.DurationFormat.Short)
  157. }
  158. UM.RecolorImage {
  159. id: lengthIcon
  160. anchors.right: lengthSpec.left
  161. anchors.rightMargin: UM.Theme.getSize("default_margin").width/2
  162. anchors.verticalCenter: parent.verticalCenter
  163. width: UM.Theme.getSize("save_button_specs_icons").width
  164. height: UM.Theme.getSize("save_button_specs_icons").height
  165. sourceSize.width: width
  166. sourceSize.height: width
  167. color: UM.Theme.getColor("text_subtext")
  168. source: UM.Theme.getIcon("category_material")
  169. }
  170. Label{
  171. id: lengthSpec
  172. anchors.right: parent.right
  173. anchors.verticalCenter: parent.verticalCenter
  174. font: UM.Theme.getFont("small")
  175. color: UM.Theme.getColor("text_subtext")
  176. text:
  177. {
  178. var amounts = [];
  179. if(base.printMaterialAmounts) {
  180. for(var index = 0; index < base.printMaterialAmounts.length; index++) {
  181. amounts.push(base.printMaterialAmounts[index].toFixed(2));
  182. }
  183. } else {
  184. amounts = ["0.00"];
  185. }
  186. return catalog.i18nc("@label", "%1 m").arg(amounts.join(" + "));
  187. }
  188. }
  189. }
  190. }
  191. }