JobSpecs.qml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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: PrintInformation.baseName
  13. UM.I18nCatalog { id: catalog; name:"cura"}
  14. height: childrenRect.height
  15. Connections
  16. {
  17. target: backgroundItem
  18. onHasMesh:
  19. {
  20. if (PrintInformation.baseName == "")
  21. {
  22. PrintInformation.baseName = name;
  23. }
  24. }
  25. }
  26. onActivityChanged: {
  27. if (activity == false) {
  28. //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)
  29. PrintInformation.baseName = ''
  30. }
  31. }
  32. Rectangle
  33. {
  34. id: jobNameRow
  35. anchors.top: parent.top
  36. anchors.right: parent.right
  37. height: UM.Theme.getSize("jobspecs_line").height
  38. visible: base.activity
  39. Item
  40. {
  41. width: parent.width
  42. height: parent.height
  43. Button
  44. {
  45. id: printJobPencilIcon
  46. anchors.right: parent.right
  47. anchors.verticalCenter: parent.verticalCenter
  48. width: UM.Theme.getSize("save_button_specs_icons").width
  49. height: UM.Theme.getSize("save_button_specs_icons").height
  50. onClicked:
  51. {
  52. printJobTextfield.selectAll();
  53. printJobTextfield.focus = true;
  54. }
  55. style: ButtonStyle
  56. {
  57. background: Item
  58. {
  59. UM.RecolorImage
  60. {
  61. width: UM.Theme.getSize("save_button_specs_icons").width;
  62. height: UM.Theme.getSize("save_button_specs_icons").height;
  63. sourceSize.width: width;
  64. sourceSize.height: width;
  65. color: control.hovered ? UM.Theme.getColor("text_scene_hover") : UM.Theme.getColor("text_scene");
  66. source: UM.Theme.getIcon("pencil");
  67. }
  68. }
  69. }
  70. }
  71. TextField
  72. {
  73. id: printJobTextfield
  74. anchors.right: printJobPencilIcon.left
  75. anchors.rightMargin: Math.round(UM.Theme.getSize("default_margin").width / 2)
  76. height: UM.Theme.getSize("jobspecs_line").height
  77. width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50)
  78. maximumLength: 120
  79. property int unremovableSpacing: 5
  80. text: PrintInformation.jobName
  81. horizontalAlignment: TextInput.AlignRight
  82. onTextChanged: {
  83. PrintInformation.setJobName(text);
  84. }
  85. onEditingFinished: {
  86. if (printJobTextfield.text != ''){
  87. printJobTextfield.focus = false;
  88. }
  89. }
  90. validator: RegExpValidator {
  91. regExp: /^[^\\ \/ \*\?\|\[\]]*$/
  92. }
  93. style: TextFieldStyle{
  94. textColor: UM.Theme.getColor("text_scene");
  95. font: UM.Theme.getFont("default_bold");
  96. background: Rectangle {
  97. opacity: 0
  98. border.width: 0
  99. }
  100. }
  101. }
  102. }
  103. }
  104. Row {
  105. id: additionalComponentsRow
  106. anchors.top: jobNameRow.bottom
  107. anchors.right: parent.right
  108. }
  109. Label
  110. {
  111. id: boundingSpec
  112. anchors.top: jobNameRow.bottom
  113. anchors.right: additionalComponentsRow.left
  114. anchors.rightMargin:
  115. {
  116. if (additionalComponentsRow.width > 0)
  117. {
  118. return UM.Theme.getSize("default_margin").width
  119. }
  120. else
  121. {
  122. return 0;
  123. }
  124. }
  125. height: UM.Theme.getSize("jobspecs_line").height
  126. verticalAlignment: Text.AlignVCenter
  127. font: UM.Theme.getFont("small")
  128. color: UM.Theme.getColor("text_scene")
  129. text: CuraApplication.getSceneBoundingBoxString
  130. }
  131. Component.onCompleted: {
  132. base.addAdditionalComponents("jobSpecsButton")
  133. }
  134. Connections {
  135. target: CuraApplication
  136. onAdditionalComponentsChanged: base.addAdditionalComponents("jobSpecsButton")
  137. }
  138. function addAdditionalComponents (areaId) {
  139. if(areaId == "jobSpecsButton") {
  140. for (var component in CuraApplication.additionalComponents["jobSpecsButton"]) {
  141. CuraApplication.additionalComponents["jobSpecsButton"][component].parent = additionalComponentsRow
  142. }
  143. }
  144. }
  145. }