JobSpecs.qml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. onEditingFinished: {
  72. PrintInformation.setJobName(text, true);
  73. if (printJobTextfield.text != ''){
  74. printJobTextfield.focus = false;
  75. }
  76. }
  77. validator: RegExpValidator {
  78. regExp: /^[^\\ \/ \*\?\|\[\]]*$/
  79. }
  80. style: TextFieldStyle{
  81. textColor: UM.Theme.getColor("text_scene");
  82. font: UM.Theme.getFont("default_bold");
  83. background: Rectangle {
  84. opacity: 0
  85. border.width: 0
  86. }
  87. }
  88. }
  89. }
  90. }
  91. Row {
  92. id: additionalComponentsRow
  93. anchors.top: jobNameRow.bottom
  94. anchors.right: parent.right
  95. }
  96. Label
  97. {
  98. id: boundingSpec
  99. anchors.top: jobNameRow.bottom
  100. anchors.right: additionalComponentsRow.left
  101. anchors.rightMargin:
  102. {
  103. if (additionalComponentsRow.width > 0)
  104. {
  105. return UM.Theme.getSize("default_margin").width
  106. }
  107. else
  108. {
  109. return 0;
  110. }
  111. }
  112. height: UM.Theme.getSize("jobspecs_line").height
  113. verticalAlignment: Text.AlignVCenter
  114. font: UM.Theme.getFont("small")
  115. color: UM.Theme.getColor("text_scene")
  116. text: CuraApplication.getSceneBoundingBoxString
  117. }
  118. Component.onCompleted: {
  119. base.addAdditionalComponents("jobSpecsButton")
  120. }
  121. Connections {
  122. target: CuraApplication
  123. onAdditionalComponentsChanged: base.addAdditionalComponents("jobSpecsButton")
  124. }
  125. function addAdditionalComponents (areaId) {
  126. if(areaId == "jobSpecsButton") {
  127. for (var component in CuraApplication.additionalComponents["jobSpecsButton"]) {
  128. CuraApplication.additionalComponents["jobSpecsButton"][component].parent = additionalComponentsRow
  129. }
  130. }
  131. }
  132. }