JobSpecs.qml 4.9 KB

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