JobSpecs.qml 4.8 KB

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