JobSpecs.qml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // Copyright (c) 2018 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. {
  11. id: base
  12. property bool activity: CuraApplication.platformActivity
  13. property string fileBaseName: 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. Button
  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. onClicked:
  43. {
  44. printJobTextfield.selectAll()
  45. printJobTextfield.focus = true
  46. }
  47. style: ButtonStyle
  48. {
  49. background: Item
  50. {
  51. UM.RecolorImage
  52. {
  53. width: UM.Theme.getSize("save_button_specs_icons").width
  54. height: UM.Theme.getSize("save_button_specs_icons").height
  55. sourceSize.width: width
  56. sourceSize.height: width
  57. color: control.hovered ? UM.Theme.getColor("small_button_text_hover") : UM.Theme.getColor("small_button_text")
  58. source: UM.Theme.getIcon("pencil")
  59. }
  60. }
  61. }
  62. }
  63. TextField
  64. {
  65. id: printJobTextfield
  66. anchors.left: printJobPencilIcon.right
  67. anchors.leftMargin: UM.Theme.getSize("narrow_margin").width
  68. height: UM.Theme.getSize("jobspecs_line").height
  69. width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50)
  70. maximumLength: 120
  71. text: PrintInformation.jobName
  72. horizontalAlignment: TextInput.AlignLeft
  73. onEditingFinished:
  74. {
  75. var new_name = text == "" ? catalog.i18nc("@text Print job name", "Untitled") : text
  76. PrintInformation.setJobName(new_name, true)
  77. printJobTextfield.focus = false
  78. }
  79. validator: RegExpValidator {
  80. regExp: /^[^\\\/\*\?\|\[\]]*$/
  81. }
  82. style: TextFieldStyle
  83. {
  84. textColor: UM.Theme.getColor("text_scene")
  85. font: UM.Theme.getFont("default")
  86. background: Rectangle
  87. {
  88. opacity: 0
  89. border.width: 0
  90. }
  91. }
  92. }
  93. }
  94. Label
  95. {
  96. id: boundingSpec
  97. anchors.top: jobNameRow.bottom
  98. anchors.left: parent.left
  99. height: UM.Theme.getSize("jobspecs_line").height
  100. verticalAlignment: Text.AlignVCenter
  101. font: UM.Theme.getFont("default")
  102. color: UM.Theme.getColor("text_scene")
  103. text: CuraApplication.getSceneBoundingBoxString
  104. }
  105. Row
  106. {
  107. id: additionalComponentsRow
  108. anchors.top: boundingSpec.top
  109. anchors.bottom: boundingSpec.bottom
  110. anchors.left: boundingSpec.right
  111. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  112. }
  113. Component.onCompleted:
  114. {
  115. base.addAdditionalComponents("jobSpecsButton")
  116. }
  117. Connections
  118. {
  119. target: CuraApplication
  120. onAdditionalComponentsChanged: base.addAdditionalComponents("jobSpecsButton")
  121. }
  122. function addAdditionalComponents(areaId)
  123. {
  124. if (areaId == "jobSpecsButton")
  125. {
  126. for (var component in CuraApplication.additionalComponents["jobSpecsButton"])
  127. {
  128. CuraApplication.additionalComponents["jobSpecsButton"][component].parent = additionalComponentsRow
  129. }
  130. }
  131. }
  132. }