JobSpecs.qml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 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. Rectangle {
  9. id: base;
  10. property real progress: UM.Backend.progress;
  11. property bool activity: Printer.getPlatformActivity;
  12. Behavior on progress { NumberAnimation { duration: 250; } }
  13. property int totalHeight: childrenRect.height + UM.Theme.sizes.default_margin.height*1.5
  14. property string fileBaseName
  15. property variant activeMachineInstance: UM.MachineManager.activeMachineInstance
  16. onActiveMachineInstanceChanged:
  17. {
  18. base.createFileName()
  19. }
  20. UM.I18nCatalog { id: catalog; name:"cura"}
  21. property variant printDuration: PrintInformation.currentPrintTime;
  22. property real printMaterialAmount: PrintInformation.materialAmount;
  23. width: 240
  24. height: 50
  25. color: "transparent"
  26. function createFileName(){
  27. var splitMachineName = UM.MachineManager.activeMachineInstance.split(" ")
  28. var abbrMachine = ''
  29. for (var i = 0; i < splitMachineName.length; i++){
  30. if (splitMachineName[i].search(/ultimaker/i) != -1){
  31. abbrMachine += 'UM'
  32. }
  33. else{
  34. if (splitMachineName[i].charAt(0).search(/[0-9]/g) == -1)
  35. abbrMachine += splitMachineName[i].charAt(0)
  36. }
  37. var regExpAdditives = /[0-9\+]/g;
  38. var resultAdditives = splitMachineName[i].match(regExpAdditives);
  39. if (resultAdditives != null){
  40. for (var j = 0; j < resultAdditives.length; j++){
  41. abbrMachine += resultAdditives[j]
  42. }
  43. }
  44. }
  45. printJobTextfield.text = abbrMachine + '_' + base.fileBaseName
  46. }
  47. Connections {
  48. target: openDialog
  49. onHasMesh: {
  50. if(base.fileBaseName == ''){
  51. base.fileBaseName = name
  52. base.createFileName()
  53. }
  54. }
  55. }
  56. onActivityChanged: {
  57. if (activity == false){
  58. base.fileBaseName = ''
  59. base.createFileName()
  60. }
  61. }
  62. TextField {
  63. id: printJobTextfield
  64. anchors.right: parent.right
  65. anchors.rightMargin: UM.Theme.sizes.default_margin.width;
  66. height: UM.Theme.sizes.sidebar_inputFields.height
  67. width: base.width
  68. property int unremovableSpacing: 5
  69. text: ''
  70. horizontalAlignment: TextInput.AlignRight
  71. onTextChanged: Printer.setJobName(text)
  72. onEditingFinished: {
  73. if (printJobTextfield.text != ''){
  74. printJobTextfield.focus = false
  75. }
  76. }
  77. validator: RegExpValidator {
  78. regExp: /^[^\\ \/ \.]*$/
  79. }
  80. style: TextFieldStyle{
  81. textColor: UM.Theme.colors.setting_control_text;
  82. font: UM.Theme.fonts.default;
  83. background: Rectangle {
  84. opacity: 0
  85. border.width: 0
  86. }
  87. }
  88. }
  89. Rectangle {
  90. id: specsRow
  91. implicitWidth: base.width
  92. implicitHeight: UM.Theme.sizes.sidebar_specs_bar.height
  93. anchors.top: printJobTextfield.bottom
  94. color: "transparent"
  95. visible: base.progress > 0.99 && base.activity == true
  96. Item{
  97. id: time
  98. width: childrenRect.width;
  99. height: parent.height
  100. anchors.left: parent.left
  101. anchors.leftMargin: UM.Theme.sizes.default_margin.width
  102. anchors.top: parent.top
  103. visible: base.printMaterialAmount > 0 ? true : false
  104. UM.RecolorImage {
  105. id: timeIcon
  106. anchors.verticalCenter: parent.verticalCenter
  107. anchors.left: parent.left
  108. width: UM.Theme.sizes.save_button_specs_icons.width
  109. height: UM.Theme.sizes.save_button_specs_icons.height
  110. sourceSize.width: width
  111. sourceSize.height: width
  112. color: UM.Theme.colors.text_hover
  113. source: UM.Theme.icons.print_time;
  114. }
  115. Label{
  116. id: timeSpec
  117. anchors.verticalCenter: parent.verticalCenter
  118. anchors.left: timeIcon.right
  119. anchors.leftMargin: UM.Theme.sizes.default_margin.width/2
  120. font: UM.Theme.fonts.default
  121. color: UM.Theme.colors.text
  122. text: (!base.printDuration || !base.printDuration.valid) ? "" : base.printDuration.getDisplayString(UM.DurationFormat.Short)
  123. }
  124. }
  125. Item{
  126. width: parent.width / 100 * 55
  127. height: parent.height
  128. anchors.left: time.right
  129. anchors.leftMargin: UM.Theme.sizes.default_margin.width;
  130. anchors.top: parent.top
  131. visible: base.printMaterialAmount > 0 ? true : false
  132. UM.RecolorImage {
  133. id: lengthIcon
  134. anchors.verticalCenter: parent.verticalCenter
  135. anchors.left: parent.left
  136. width: UM.Theme.sizes.save_button_specs_icons.width
  137. height: UM.Theme.sizes.save_button_specs_icons.height
  138. sourceSize.width: width
  139. sourceSize.height: width
  140. color: UM.Theme.colors.text_hover
  141. source: UM.Theme.icons.category_material;
  142. }
  143. Label{
  144. id: lengthSpec
  145. anchors.verticalCenter: parent.verticalCenter
  146. anchors.left: lengthIcon.right
  147. anchors.leftMargin: UM.Theme.sizes.default_margin.width/2
  148. font: UM.Theme.fonts.default
  149. color: UM.Theme.colors.text
  150. text: base.printMaterialAmount <= 0 ? "" : catalog.i18nc("@label %1 is length of filament","%1 m").arg(base.printMaterialAmount)
  151. }
  152. }
  153. }
  154. }