MonitorPrintJobCard.qml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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.0
  5. import UM 1.3 as UM
  6. /**
  7. * A Print Job Card is essentially just a filled-in Expandable Card item. All
  8. * data within it is derived from being passed a printJob property.
  9. *
  10. * NOTE: For most labels, a fixed height with vertical alignment is used to make
  11. * layouts more deterministic (like the fixed-size textboxes used in original
  12. * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted
  13. * with '// FIXED-LINE-HEIGHT:'.
  14. */
  15. Item
  16. {
  17. id: base
  18. // The print job which all other data is derived from
  19. property var printJob: null
  20. width: parent.width
  21. height: childrenRect.height
  22. ExpandableCard
  23. {
  24. headerItem: Row
  25. {
  26. height: 48 * screenScaleFactor // TODO: Theme!
  27. anchors.left: parent.left
  28. anchors.leftMargin: 24 * screenScaleFactor // TODO: Theme!
  29. spacing: 18 * screenScaleFactor // TODO: Theme!
  30. MonitorPrintJobPreview
  31. {
  32. printJob: base.printJob
  33. size: 32 * screenScaleFactor // TODO: Theme!
  34. anchors.verticalCenter: parent.verticalCenter
  35. }
  36. Label
  37. {
  38. text: printJob && printJob.name ? printJob.name : ""
  39. color: "#374355"
  40. elide: Text.ElideRight
  41. font: UM.Theme.getFont("medium") // 14pt, regular
  42. anchors.verticalCenter: parent.verticalCenter
  43. width: 216 * screenScaleFactor // TODO: Theme! (Should match column size)
  44. // FIXED-LINE-HEIGHT:
  45. height: 18 * screenScaleFactor // TODO: Theme!
  46. verticalAlignment: Text.AlignVCenter
  47. }
  48. Label
  49. {
  50. text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : ""
  51. color: "#374355"
  52. elide: Text.ElideRight
  53. font: UM.Theme.getFont("medium") // 14pt, regular
  54. anchors.verticalCenter: parent.verticalCenter
  55. width: 216 * screenScaleFactor // TODO: Theme! (Should match column size)
  56. // FIXED-LINE-HEIGHT:
  57. height: 18 * screenScaleFactor // TODO: Theme!
  58. verticalAlignment: Text.AlignVCenter
  59. }
  60. Item
  61. {
  62. anchors.verticalCenter: parent.verticalCenter
  63. height: 18 * screenScaleFactor // TODO: This should be childrenRect.height but QML throws warnings
  64. width: childrenRect.width
  65. Label
  66. {
  67. id: printerAssignmentLabel
  68. anchors.verticalCenter: parent.verticalCenter
  69. color: "#374355"
  70. elide: Text.ElideRight
  71. font: UM.Theme.getFont("medium") // 14pt, regular
  72. text: {
  73. if (printJob !== null) {
  74. if (printJob.assignedPrinter == null)
  75. {
  76. if (printJob.state == "error")
  77. {
  78. return catalog.i18nc("@label", "Unavailable printer")
  79. }
  80. return catalog.i18nc("@label", "First available")
  81. }
  82. return printJob.assignedPrinter.name
  83. }
  84. return ""
  85. }
  86. visible: printJob
  87. // FIXED-LINE-HEIGHT:
  88. height: 18 * screenScaleFactor // TODO: Theme!
  89. verticalAlignment: Text.AlignVCenter
  90. }
  91. Row
  92. {
  93. id: printerFamilyPills
  94. anchors
  95. {
  96. left: printerAssignmentLabel.right;
  97. leftMargin: 12 // TODO: Theme!
  98. verticalCenter: parent.verticalCenter
  99. }
  100. height: childrenRect.height
  101. spacing: 6 // TODO: Theme!
  102. Repeater
  103. {
  104. id: compatiblePills
  105. delegate: MonitorPrinterPill
  106. {
  107. text: modelData
  108. }
  109. model: printJob ? printJob.compatibleMachineFamilies : []
  110. }
  111. }
  112. }
  113. }
  114. drawerItem: Row
  115. {
  116. anchors
  117. {
  118. left: parent.left
  119. leftMargin: 74 * screenScaleFactor // TODO: Theme!
  120. }
  121. height: 108 * screenScaleFactor // TODO: Theme!
  122. spacing: 18 * screenScaleFactor // TODO: Theme!
  123. MonitorPrinterConfiguration
  124. {
  125. id: printerConfiguration
  126. anchors.verticalCenter: parent.verticalCenter
  127. buildplate: "Glass"
  128. configurations:
  129. [
  130. base.printJob.configuration.extruderConfigurations[0],
  131. base.printJob.configuration.extruderConfigurations[1]
  132. ]
  133. height: 72 * screenScaleFactor // TODO: Theme!
  134. }
  135. Label {
  136. text: printJob && printJob.owner ? printJob.owner : ""
  137. color: "#374355" // TODO: Theme!
  138. elide: Text.ElideRight
  139. font: UM.Theme.getFont("medium") // 14pt, regular
  140. anchors.top: printerConfiguration.top
  141. // FIXED-LINE-HEIGHT:
  142. height: 18 * screenScaleFactor // TODO: Theme!
  143. verticalAlignment: Text.AlignVCenter
  144. }
  145. }
  146. }
  147. PrintJobContextMenu
  148. {
  149. id: contextButton
  150. anchors
  151. {
  152. right: parent.right;
  153. rightMargin: 8 * screenScaleFactor // TODO: Theme!
  154. top: parent.top
  155. topMargin: 8 * screenScaleFactor // TODO: Theme!
  156. }
  157. printJob: base.printJob
  158. width: 32 * screenScaleFactor // TODO: Theme!
  159. height: 32 * screenScaleFactor // TODO: Theme!
  160. }
  161. }