JobSpecs.qml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 2.1
  5. import QtQuick.Layouts 1.1
  6. import UM 1.5 as UM
  7. import Cura 1.0 as Cura
  8. Item
  9. {
  10. id: base
  11. property bool activity: CuraApplication.platformActivity
  12. property string fileBaseName: (PrintInformation === null) ? "" : PrintInformation.baseName
  13. UM.I18nCatalog
  14. {
  15. id: catalog
  16. name: "cura"
  17. }
  18. width: childrenRect.width
  19. height: childrenRect.height
  20. onActivityChanged:
  21. {
  22. if (!activity)
  23. {
  24. // When there is no mesh in the buildplate; the printJobTextField is set to an empty string so it doesn't
  25. // 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. font: UM.Theme.getFont("default")
  81. color: UM.Theme.getColor("text_scene")
  82. background: Item {}
  83. selectByMouse: true
  84. }
  85. }
  86. UM.Label
  87. {
  88. id: boundingSpec
  89. anchors.top: jobNameRow.bottom
  90. anchors.left: parent.left
  91. height: UM.Theme.getSize("jobspecs_line").height
  92. color: UM.Theme.getColor("text_scene")
  93. text: CuraApplication.getSceneBoundingBoxString
  94. }
  95. Row
  96. {
  97. id: additionalComponentsRow
  98. anchors.top: boundingSpec.top
  99. anchors.bottom: boundingSpec.bottom
  100. anchors.left: boundingSpec.right
  101. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  102. }
  103. Component.onCompleted: base.addAdditionalComponents("jobSpecsButton")
  104. Connections
  105. {
  106. target: CuraApplication
  107. function onAdditionalComponentsChanged(areaId) { base.addAdditionalComponents("jobSpecsButton") }
  108. }
  109. function addAdditionalComponents(areaId)
  110. {
  111. if (areaId == "jobSpecsButton")
  112. {
  113. for (var component in CuraApplication.additionalComponents["jobSpecsButton"])
  114. {
  115. CuraApplication.additionalComponents["jobSpecsButton"][component].parent = additionalComponentsRow
  116. }
  117. }
  118. }
  119. }