ClusterControlItem.qml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. import QtQuick 2.2
  2. import QtQuick.Controls 1.4
  3. import UM 1.3 as UM
  4. import Cura 1.0 as Cura
  5. Component
  6. {
  7. Rectangle
  8. {
  9. id: base
  10. property var manager: Cura.MachineManager.printerOutputDevices[0]
  11. anchors.fill: parent
  12. color: UM.Theme.getColor("viewport_background")
  13. property var lineColor: "#DCDCDC" // TODO: Should be linked to theme.
  14. property var cornerRadius: 4 * screenScaleFactor // TODO: Should be linked to theme.
  15. visible: manager != null
  16. UM.I18nCatalog
  17. {
  18. id: catalog
  19. name: "cura"
  20. }
  21. Label
  22. {
  23. id: activePrintersLabel
  24. font: UM.Theme.getFont("large")
  25. anchors.horizontalCenter: parent.horizontalCenter
  26. anchors.topMargin: UM.Theme.getSize("default_margin").height
  27. anchors.top: parent.top
  28. text: Cura.MachineManager.printerOutputDevices[0].name
  29. }
  30. Rectangle
  31. {
  32. id: printJobArea
  33. border.width: UM.Theme.getSize("default_lining").width
  34. border.color: lineColor
  35. anchors.top: activePrintersLabel.bottom
  36. anchors.topMargin: UM.Theme.getSize("default_margin").height
  37. anchors.left: parent.left
  38. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  39. anchors.right: parent.right
  40. anchors.rightMargin:UM.Theme.getSize("default_margin").width
  41. radius: cornerRadius
  42. height: childrenRect.height
  43. Item
  44. {
  45. id: printJobTitleBar
  46. width: parent.width
  47. height: printJobTitleLabel.height + 2 * UM.Theme.getSize("default_margin").height
  48. Label
  49. {
  50. id: printJobTitleLabel
  51. anchors.left: parent.left
  52. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  53. anchors.top: parent.top
  54. anchors.topMargin: UM.Theme.getSize("default_margin").height
  55. text: catalog.i18nc("@title", "Print jobs")
  56. font: UM.Theme.getFont("default")
  57. opacity: 0.75
  58. }
  59. Rectangle
  60. {
  61. anchors.bottom: parent.bottom
  62. height: UM.Theme.getSize("default_lining").width
  63. color: lineColor
  64. width: parent.width
  65. }
  66. }
  67. Column
  68. {
  69. id: printJobColumn
  70. anchors.top: printJobTitleBar.bottom
  71. anchors.topMargin: UM.Theme.getSize("default_margin").height
  72. anchors.left: parent.left
  73. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  74. anchors.right: parent.right
  75. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  76. //TODO; It's probably nicer to do this with a dynamic data model instead of hardcoding this.
  77. //But you know the drill; time constraints don't result in elegant code.
  78. Item
  79. {
  80. width: parent.width
  81. height: childrenRect.height
  82. opacity: 0.65
  83. Label
  84. {
  85. text: catalog.i18nc("@label", "Printing")
  86. font: UM.Theme.getFont("very_small")
  87. }
  88. Label
  89. {
  90. text: manager.numJobsPrinting
  91. font: UM.Theme.getFont("small")
  92. anchors.right: parent.right
  93. }
  94. }
  95. Item
  96. {
  97. width: parent.width
  98. height: childrenRect.height
  99. opacity: 0.65
  100. Label
  101. {
  102. text: catalog.i18nc("@label", "Queued")
  103. font: UM.Theme.getFont("very_small")
  104. }
  105. Label
  106. {
  107. text: manager.numJobsQueued
  108. font: UM.Theme.getFont("small")
  109. anchors.right: parent.right
  110. }
  111. }
  112. }
  113. OpenPanelButton
  114. {
  115. anchors.top: printJobColumn.bottom
  116. anchors.left: parent.left
  117. anchors.right: parent.right
  118. anchors.margins: UM.Theme.getSize("default_margin").height
  119. id: configButton
  120. onClicked: base.manager.openPrintJobControlPanel()
  121. text: catalog.i18nc("@action:button", "View print jobs")
  122. }
  123. Item
  124. {
  125. // spacer
  126. anchors.top: configButton.bottom
  127. width: UM.Theme.getSize("default_margin").width
  128. height: UM.Theme.getSize("default_margin").height
  129. }
  130. }
  131. Rectangle
  132. {
  133. id: printersArea
  134. border.width: UM.Theme.getSize("default_lining").width
  135. border.color: lineColor
  136. anchors.top: printJobArea.bottom
  137. anchors.topMargin: UM.Theme.getSize("default_margin").height
  138. anchors.left: parent.left
  139. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  140. anchors.right: parent.right
  141. anchors.rightMargin:UM.Theme.getSize("default_margin").width
  142. radius: cornerRadius
  143. height: childrenRect.height
  144. Item
  145. {
  146. id: printersTitleBar
  147. width: parent.width
  148. height: printJobTitleLabel.height + 2 * UM.Theme.getSize("default_margin").height
  149. Label
  150. {
  151. id: printersTitleLabel
  152. anchors.left: parent.left
  153. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  154. anchors.top: parent.top
  155. anchors.topMargin: UM.Theme.getSize("default_margin").height
  156. text: catalog.i18nc("@label:title", "Printers")
  157. font: UM.Theme.getFont("default")
  158. opacity: 0.75
  159. }
  160. Rectangle
  161. {
  162. anchors.bottom: parent.bottom
  163. height: UM.Theme.getSize("default_lining").width
  164. color: lineColor
  165. width: parent.width
  166. }
  167. }
  168. Column
  169. {
  170. id: printersColumn
  171. anchors.top: printersTitleBar.bottom
  172. anchors.topMargin: UM.Theme.getSize("default_margin").height
  173. anchors.left: parent.left
  174. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  175. anchors.right: parent.right
  176. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  177. Repeater
  178. {
  179. model: manager.connectedPrintersTypeCount
  180. Item
  181. {
  182. width: parent.width
  183. height: childrenRect.height
  184. opacity: 0.65
  185. Label
  186. {
  187. text: modelData.machine_type
  188. font: UM.Theme.getFont("very_small")
  189. }
  190. Label
  191. {
  192. text: modelData.count
  193. font: UM.Theme.getFont("small")
  194. anchors.right: parent.right
  195. }
  196. }
  197. }
  198. }
  199. OpenPanelButton
  200. {
  201. anchors.top: printersColumn.bottom
  202. anchors.left: parent.left
  203. anchors.right: parent.right
  204. anchors.margins: UM.Theme.getSize("default_margin").height
  205. id: printerConfigButton
  206. onClicked: base.manager.openPrinterControlPanel()
  207. text: catalog.i18nc("@action:button", "View printers")
  208. }
  209. Item
  210. {
  211. // spacer
  212. anchors.top: printerConfigButton.bottom
  213. width: UM.Theme.getSize("default_margin").width
  214. height: UM.Theme.getSize("default_margin").height
  215. }
  216. }
  217. }
  218. }