JobSpecs.qml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 2.2
  5. import QtQuick.Controls.Styles 2.2
  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("Pen")
  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. /*
  93. style: TextFieldStyle
  94. {
  95. textColor: UM.Theme.getColor("text_scene")
  96. font: UM.Theme.getFont("default")
  97. background: Rectangle
  98. {
  99. opacity: 0
  100. border.width: 0
  101. }
  102. }
  103. */
  104. }
  105. }
  106. Label
  107. {
  108. id: boundingSpec
  109. anchors.top: jobNameRow.bottom
  110. anchors.left: parent.left
  111. height: UM.Theme.getSize("jobspecs_line").height
  112. verticalAlignment: Text.AlignVCenter
  113. font: UM.Theme.getFont("default")
  114. color: UM.Theme.getColor("text_scene")
  115. text: CuraApplication.getSceneBoundingBoxString
  116. }
  117. Row
  118. {
  119. id: additionalComponentsRow
  120. anchors.top: boundingSpec.top
  121. anchors.bottom: boundingSpec.bottom
  122. anchors.left: boundingSpec.right
  123. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  124. }
  125. Component.onCompleted:
  126. {
  127. base.addAdditionalComponents("jobSpecsButton")
  128. }
  129. Connections
  130. {
  131. target: CuraApplication
  132. function onAdditionalComponentsChanged(areaId) { base.addAdditionalComponents("jobSpecsButton") }
  133. }
  134. function addAdditionalComponents(areaId)
  135. {
  136. if (areaId == "jobSpecsButton")
  137. {
  138. for (var component in CuraApplication.additionalComponents["jobSpecsButton"])
  139. {
  140. CuraApplication.additionalComponents["jobSpecsButton"][component].parent = additionalComponentsRow
  141. }
  142. }
  143. }
  144. }