JobSpecs.qml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 === 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. 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 === null) ? "" : PrintInformation.jobName
  72. horizontalAlignment: TextInput.AlignLeft
  73. property string textBeforeEdit: ""
  74. onActiveFocusChanged:
  75. {
  76. if (activeFocus)
  77. {
  78. textBeforeEdit = text
  79. }
  80. }
  81. onEditingFinished:
  82. {
  83. if (text != textBeforeEdit) {
  84. var new_name = text == "" ? catalog.i18nc("@text Print job name", "Untitled") : text
  85. PrintInformation.setJobName(new_name, true)
  86. }
  87. printJobTextfield.focus = false
  88. }
  89. validator: RegExpValidator {
  90. regExp: /^[^\\\/\*\?\|\[\]]*$/
  91. }
  92. style: TextFieldStyle
  93. {
  94. textColor: UM.Theme.getColor("text_scene")
  95. font: UM.Theme.getFont("default")
  96. background: Rectangle
  97. {
  98. opacity: 0
  99. border.width: 0
  100. }
  101. }
  102. }
  103. }
  104. Label
  105. {
  106. id: boundingSpec
  107. anchors.top: jobNameRow.bottom
  108. anchors.left: parent.left
  109. height: UM.Theme.getSize("jobspecs_line").height
  110. verticalAlignment: Text.AlignVCenter
  111. font: UM.Theme.getFont("default")
  112. color: UM.Theme.getColor("text_scene")
  113. text: CuraApplication.getSceneBoundingBoxString
  114. }
  115. Row
  116. {
  117. id: additionalComponentsRow
  118. anchors.top: boundingSpec.top
  119. anchors.bottom: boundingSpec.bottom
  120. anchors.left: boundingSpec.right
  121. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  122. }
  123. Component.onCompleted:
  124. {
  125. base.addAdditionalComponents("jobSpecsButton")
  126. }
  127. Connections
  128. {
  129. target: CuraApplication
  130. onAdditionalComponentsChanged: base.addAdditionalComponents("jobSpecsButton")
  131. }
  132. function addAdditionalComponents(areaId)
  133. {
  134. if (areaId == "jobSpecsButton")
  135. {
  136. for (var component in CuraApplication.additionalComponents["jobSpecsButton"])
  137. {
  138. CuraApplication.additionalComponents["jobSpecsButton"][component].parent = additionalComponentsRow
  139. }
  140. }
  141. }
  142. }