JobSpecs.qml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // Copyright (c) 2017 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. Item {
  10. id: base
  11. property bool activity: CuraApplication.platformActivity
  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. height: childrenRect.height
  20. Connections
  21. {
  22. target: backgroundItem
  23. onHasMesh:
  24. {
  25. base.fileBaseName = name
  26. }
  27. }
  28. onActivityChanged: {
  29. if (activity == true && base.fileBaseName == ''){
  30. //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)
  31. 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)
  32. printJobTextfield.text = PrintInformation.createJobName(base.fileBaseName);
  33. }
  34. if (activity == true && base.fileBaseName != ''){
  35. //this runs in all other cases where there is a mesh on the buildplate (activity == true). It uses the fileBaseName from the hasMesh signal
  36. printJobTextfield.text = PrintInformation.createJobName(base.fileBaseName);
  37. }
  38. if (activity == false){
  39. //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)
  40. printJobTextfield.text = '';
  41. }
  42. }
  43. Rectangle
  44. {
  45. id: jobNameRow
  46. anchors.top: parent.top
  47. anchors.right: parent.right
  48. height: UM.Theme.getSize("jobspecs_line").height
  49. visible: base.activity
  50. Item
  51. {
  52. width: parent.width
  53. height: parent.height
  54. Button
  55. {
  56. id: printJobPencilIcon
  57. anchors.right: parent.right
  58. anchors.verticalCenter: parent.verticalCenter
  59. width: UM.Theme.getSize("save_button_specs_icons").width
  60. height: UM.Theme.getSize("save_button_specs_icons").height
  61. onClicked:
  62. {
  63. printJobTextfield.selectAll();
  64. printJobTextfield.focus = true;
  65. }
  66. style: ButtonStyle
  67. {
  68. background: Item
  69. {
  70. UM.RecolorImage
  71. {
  72. width: UM.Theme.getSize("save_button_specs_icons").width;
  73. height: UM.Theme.getSize("save_button_specs_icons").height;
  74. sourceSize.width: width;
  75. sourceSize.height: width;
  76. color: control.hovered ? UM.Theme.getColor("text_scene_hover") : UM.Theme.getColor("text_scene");
  77. source: UM.Theme.getIcon("pencil");
  78. }
  79. }
  80. }
  81. }
  82. TextField
  83. {
  84. id: printJobTextfield
  85. anchors.right: printJobPencilIcon.left
  86. anchors.rightMargin: UM.Theme.getSize("default_margin").width/2
  87. height: UM.Theme.getSize("jobspecs_line").height
  88. width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50)
  89. maximumLength: 120
  90. property int unremovableSpacing: 5
  91. text: ''
  92. horizontalAlignment: TextInput.AlignRight
  93. onTextChanged: {
  94. PrintInformation.setJobName(text);
  95. }
  96. onEditingFinished: {
  97. if (printJobTextfield.text != ''){
  98. printJobTextfield.focus = false;
  99. }
  100. }
  101. validator: RegExpValidator {
  102. regExp: /^[^\\ \/ \*\?\|\[\]]*$/
  103. }
  104. style: TextFieldStyle{
  105. textColor: UM.Theme.getColor("text_scene");
  106. font: UM.Theme.getFont("default_bold");
  107. background: Rectangle {
  108. opacity: 0
  109. border.width: 0
  110. }
  111. }
  112. }
  113. }
  114. }
  115. Text
  116. {
  117. id: boundingSpec
  118. anchors.top: jobNameRow.bottom
  119. anchors.right: parent.right
  120. height: UM.Theme.getSize("jobspecs_line").height
  121. verticalAlignment: Text.AlignVCenter
  122. font: UM.Theme.getFont("small")
  123. color: UM.Theme.getColor("text_scene")
  124. text: CuraApplication.getSceneBoundingBoxString
  125. }
  126. }