JobSpecs.qml 4.9 KB

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