JobSpecs.qml 4.9 KB

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