JobSpecs.qml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // Copyright (c) 2021 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.5 as UM
  8. import Cura 1.0 as Cura
  9. Item
  10. {
  11. id: base
  12. property bool activity: CuraApplication.platformActivity
  13. property string fileBaseName: (PrintInformation === null) ? "" : PrintInformation.baseName
  14. UM.I18nCatalog
  15. {
  16. id: catalog
  17. name: "cura"
  18. }
  19. width: childrenRect.width
  20. height: childrenRect.height
  21. onActivityChanged:
  22. {
  23. if (!activity)
  24. {
  25. //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)
  26. PrintInformation.baseName = ""
  27. }
  28. }
  29. Item
  30. {
  31. id: jobNameRow
  32. anchors.top: parent.top
  33. anchors.left: parent.left
  34. height: UM.Theme.getSize("jobspecs_line").height
  35. UM.SimpleButton
  36. {
  37. id: printJobPencilIcon
  38. anchors.left: parent.left
  39. anchors.verticalCenter: parent.verticalCenter
  40. width: UM.Theme.getSize("save_button_specs_icons").width
  41. height: UM.Theme.getSize("save_button_specs_icons").height
  42. iconSource: UM.Theme.getIcon("Pen")
  43. hoverColor: UM.Theme.getColor("small_button_text_hover")
  44. color: UM.Theme.getColor("small_button_text")
  45. onClicked:
  46. {
  47. printJobTextfield.selectAll()
  48. printJobTextfield.focus = true
  49. }
  50. }
  51. TextField
  52. {
  53. id: printJobTextfield
  54. anchors.left: printJobPencilIcon.right
  55. anchors.leftMargin: UM.Theme.getSize("narrow_margin").width
  56. height: UM.Theme.getSize("jobspecs_line").height
  57. width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50)
  58. maximumLength: 120
  59. text: (PrintInformation === null) ? "" : PrintInformation.jobName
  60. horizontalAlignment: TextInput.AlignLeft
  61. property string textBeforeEdit: ""
  62. onActiveFocusChanged:
  63. {
  64. if (activeFocus)
  65. {
  66. textBeforeEdit = text
  67. }
  68. }
  69. onEditingFinished:
  70. {
  71. if (text != textBeforeEdit) {
  72. var new_name = text == "" ? catalog.i18nc("@text Print job name", "Untitled") : text
  73. PrintInformation.setJobName(new_name, true)
  74. }
  75. printJobTextfield.focus = false
  76. }
  77. validator: RegExpValidator {
  78. regExp: /^[^\\\/\*\?\|\[\]]*$/
  79. }
  80. style: TextFieldStyle
  81. {
  82. textColor: UM.Theme.getColor("text_scene")
  83. font: UM.Theme.getFont("default")
  84. background: Rectangle
  85. {
  86. opacity: 0
  87. border.width: 0
  88. }
  89. }
  90. }
  91. }
  92. UM.Label
  93. {
  94. id: boundingSpec
  95. anchors.top: jobNameRow.bottom
  96. anchors.left: parent.left
  97. height: UM.Theme.getSize("jobspecs_line").height
  98. color: UM.Theme.getColor("text_scene")
  99. text: CuraApplication.getSceneBoundingBoxString
  100. }
  101. Row
  102. {
  103. id: additionalComponentsRow
  104. anchors.top: boundingSpec.top
  105. anchors.bottom: boundingSpec.bottom
  106. anchors.left: boundingSpec.right
  107. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  108. }
  109. Component.onCompleted:
  110. {
  111. base.addAdditionalComponents("jobSpecsButton")
  112. }
  113. Connections
  114. {
  115. target: CuraApplication
  116. function onAdditionalComponentsChanged(areaId) { base.addAdditionalComponents("jobSpecsButton") }
  117. }
  118. function addAdditionalComponents(areaId)
  119. {
  120. if (areaId == "jobSpecsButton")
  121. {
  122. for (var component in CuraApplication.additionalComponents["jobSpecsButton"])
  123. {
  124. CuraApplication.additionalComponents["jobSpecsButton"][component].parent = additionalComponentsRow
  125. }
  126. }
  127. }
  128. }